From 8ad12c56e2b2f7e49fcb3a81cc4354470d4262fe Mon Sep 17 00:00:00 2001 From: stevencarlislewalker Date: Wed, 9 Oct 2024 11:44:11 -0400 Subject: [PATCH] starter model --- inst/starter_models/sir_waning/README.md | 77 ++++++++++++++++++++---- 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/inst/starter_models/sir_waning/README.md b/inst/starter_models/sir_waning/README.md index 51197cbd..f698d117 100644 --- a/inst/starter_models/sir_waning/README.md +++ b/inst/starter_models/sir_waning/README.md @@ -1,15 +1,69 @@ ---- -title: "SIR with waning immunity" -index_entry: "a basic SIR model with a flow from R back to S" -author: Steve Walker ---- +SIR with waning immunity +================ +Jen Freeman, Steve Walker -Endemic pathogens can sometimes be modelled by sending R back to S, thereby controlling susceptible depletion such that new infections keep arising indefinitely. +- Packages Used +- Model + Specification +- States +- Parameters +- Dynamics +- References + +Endemic pathogens can sometimes be modelled by sending R back to S, +thereby controlling susceptible depletion such that new infections keep +arising indefinitely. This is an extension of the +[sir](https://github.com/canmod/macpan2/tree/main/inst/starter_models/sir) +model to include such immunity waning. + +# Packages Used + +The code in this article uses the following packages. + +``` r +library(ggplot2) +library(dplyr) +library(tidyr) +library(macpan2) +``` + +# Model Specification + +This model has been specified in the `sir_waning` directory +[here](https://github.com/canmod/macpan2/blob/main/inst/starter_models/sir_waning/tmb.R) +and is accessible from the `macpan2` model library (see [Example +Models](https://canmod.github.io/macpan2/articles/example_models.html) +for details). We can read in the model specification using the +`mp_tmb_library` command. + +``` r +spec = mp_tmb_library( + "starter_models" + , "sir_waning" + , package = "macpan2" +) +``` + +This specification can be used to draw the following flow diagram using +code found in the [source for this +article](https://github.com/canmod/macpan2/blob/main/inst/starter_models/sir_waning/README.Rmd). + + #> Warning in topological_sort_engine(flows, states, warn_not_dag = TRUE): + #> State network is not acyclic (i think), + #> and therefore cannot be topologically sorted. + #> Defaulting to original order where necessary. + + #> Warning in topological_sort_engine(flows, states, warn_not_dag = TRUE): + #> State network is not acyclic (i think), + #> and therefore cannot be topologically sorted. + #> Defaulting to original order where necessary. + +![](./figures/diagram-1.png) # States | variable | description | -| -------- | --------------------------------- | +|----------|-----------------------------------| | S | Number of susceptible individuals | | I | Number of infectious individuals | | R | Number of recovered individuals | @@ -19,12 +73,12 @@ The size of the total population is, $N = S + I + R$. # Parameters | variable | description | -| -------- | ------------------------------- | +|----------|---------------------------------| | $\beta$ | per capita transmission rate | | $\gamma$ | per capita recovery rate | | $\phi$ | per capita waning immunity rate | -# Dynamics +# Dynamics $$ \begin{align*} @@ -34,7 +88,4 @@ $$ \end{align*} $$ -# Model Specification - -This model has been specified in the `sir_waning` directory [here](https://github.com/canmod/macpan2/blob/main/inst/starter_models/sir_waning/tmb.R) and is accessible from the `macpan2` model library (see [Example Models](https://canmod.github.io/macpan2/articles/example_models.html) for details). - +# References