Skip to content

Commit

Permalink
Merge pull request #16 from mrc-ide/fix-code-bg
Browse files Browse the repository at this point in the history
Fix code background
  • Loading branch information
weshinsley authored Nov 14, 2024
2 parents e2bd007 + 0584d0d commit 1832013
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions differentiability.qmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Differentiability

```{r}
#| include: false
source("common.R")
```

Random walk suppression and other uses
5 changes: 5 additions & 0 deletions installation.qmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Installation

```{r}
#| include: false
source("common.R")
```

Package installation is hard, let's go shopping.

## Packages
Expand Down
5 changes: 5 additions & 0 deletions monty.qmd
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
10 changes: 9 additions & 1 deletion odin.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
5 changes: 5 additions & 0 deletions references.qmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# References {.unnumbered}

```{r}
#| include: false
source("common.R")
```

::: {#refs}
:::
2 changes: 2 additions & 0 deletions stochasticity.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down

0 comments on commit 1832013

Please sign in to comment.