From 59db85949d87e7f5a49959ec8ab69cb04af15b91 Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Thu, 14 Nov 2024 13:29:21 +0000 Subject: [PATCH 1/4] Fix code background --- common.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.R b/common.R index de629bf..14f61d8 100644 --- a/common.R +++ b/common.R @@ -17,5 +17,5 @@ r_output <- function(x) { } plain_output <- function(x) { - lang_output(x, "") + lang_output(x, "md") # not great, but at least renders nicely } From 7d59e3b2188c64b4a6e2bd46c14238773dada1ec Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Thu, 14 Nov 2024 13:30:48 +0000 Subject: [PATCH 2/4] Use common.R everywhere --- differentiability.qmd | 5 +++++ installation.qmd | 5 +++++ monty.qmd | 5 +++++ references.qmd | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/differentiability.qmd b/differentiability.qmd index 5f9caff..9c7c516 100644 --- a/differentiability.qmd +++ b/differentiability.qmd @@ -1,3 +1,8 @@ # Differentiability +```{r} +#| include: false +source("common.R") +``` + Random walk suppression and other uses diff --git a/installation.qmd b/installation.qmd index d9aa7b4..4df5484 100644 --- a/installation.qmd +++ b/installation.qmd @@ -1,5 +1,10 @@ # Installation +```{r} +#| include: false +source("common.R") +``` + Package installation is hard, let's go shopping. ## Packages diff --git a/monty.qmd b/monty.qmd index 8ddca01..3a15487 100644 --- a/monty.qmd +++ b/monty.qmd @@ -1,5 +1,10 @@ # Monty +```{r} +#| include: false +source("common.R") +``` + Before showing how to fit odin models to data, we'll focus for a bit on monty itself. If you are anxious to get on and fit the model from @sec-data-filter, you might skip ahead to @sec-inference, where we resume this. There are a bunch of things we want to cover in this chapter so likely it will be split into a few: diff --git a/references.qmd b/references.qmd index 925f7c4..eebd42a 100644 --- a/references.qmd +++ b/references.qmd @@ -1,4 +1,9 @@ # References {.unnumbered} +```{r} +#| include: false +source("common.R") +``` + ::: {#refs} ::: From adf14fa7f02aead45eb0d4441b23087f738f92cc Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Thu, 14 Nov 2024 13:35:00 +0000 Subject: [PATCH 3/4] Add equation --- odin.qmd | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/odin.qmd b/odin.qmd index d4aed6b..c4bea0e 100644 --- a/odin.qmd +++ b/odin.qmd @@ -13,7 +13,15 @@ library(odin2) ## A simple example {#sec-odin-sir} -Here is a small system of equations for an "SIR" (Susceptible-Infected-Recovered) model, implemented as a set of ordinary differential equations: +Here is a small system of differential equations for an "SIR" (Susceptible-Infected-Recovered) model: + +\begin{gather*} +\frac{dS}{dt} = -\beta S \frac{I}{N}\\ +\frac{dI}{dt} = \beta S \frac{I}{N} - \gamma I\\ +\frac{dR}{dt} = \gamma I +\end{gather*} + +And here is an implementation of these equations in `odin`: ```{r} sir <- odin({ From 0584d0d3a4aa9db852965fa24860c709f4dc460c Mon Sep 17 00:00:00 2001 From: Rich FitzJohn Date: Thu, 14 Nov 2024 13:39:03 +0000 Subject: [PATCH 4/4] Small note on binomial --- stochasticity.qmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stochasticity.qmd b/stochasticity.qmd index a4c8583..9232ec8 100644 --- a/stochasticity.qmd +++ b/stochasticity.qmd @@ -61,6 +61,8 @@ sir <- odin({ This is a discrete-time model (using `update()` and not `deriv()`) as stochastic models must run in discrete time. We use `dt` to scale the rates, and adjusting `dt` will change the way that stochasticity affects the dynamics of the system. +The call to `Binomial()` samples from a binomial distribution, returning the number of successes from `S` (or `I`) draws, each with probability `p_SI` (or `p_IR`). + ```{r} sir ```