diff --git a/compare-interventions.md b/compare-interventions.md index ad547092..2952b0f6 100644 --- a/compare-interventions.md +++ b/compare-interventions.md @@ -62,10 +62,9 @@ The Vacamole model is a deterministic model based on a system of ODEs in [Ainsli The diagram below describes the flow of individuals through the different compartments. -
- + -See `?epidemics::epidemic_vacamole` for detail on how to run the model. +See `?epidemics::model_vacamole_cpp` for detail on how to run the model. ## Comparing scenarios diff --git a/fig/simulating-transmission-rendered-plot-1.png b/fig/simulating-transmission-rendered-plot-1.png index d025a235..e8a79aa6 100644 Binary files a/fig/simulating-transmission-rendered-plot-1.png and b/fig/simulating-transmission-rendered-plot-1.png differ diff --git a/md5sum.txt b/md5sum.txt index d94d4bc6..580524bf 100644 --- a/md5sum.txt +++ b/md5sum.txt @@ -4,10 +4,10 @@ "config.yaml" "ba8182fefb4b3a156058872157fb2d7d" "site/built/config.yaml" "2023-10-31" "index.md" "adfca1a79e0106ee8b3f7731d0678b59" "site/built/index.md" "2023-11-09" "links.md" "8184cf4149eafbf03ce8da8ff0778c14" "site/built/links.md" "2023-10-31" -"episodes/simulating-transmission.Rmd" "a09170bca196d6a7ba714ddf159e2e2a" "site/built/simulating-transmission.md" "2023-11-09" -"episodes/model-choices.Rmd" "4e9de6f75c88cfbe0c265a55ea61345f" "site/built/model-choices.md" "2023-11-09" -"episodes/modelling-interventions.Rmd" "dff06995ab8d9c4b7b73f162dbf52590" "site/built/modelling-interventions.md" "2023-11-09" -"episodes/compare-interventions.Rmd" "32da6fa2116d62a3d783e397a2908c15" "site/built/compare-interventions.md" "2023-11-09" +"episodes/simulating-transmission.Rmd" "c9f03af77dc859f03b9cd57c9e76a12b" "site/built/simulating-transmission.md" "2023-11-09" +"episodes/model-choices.Rmd" "88731fa7294dce80bffeef8e51738e76" "site/built/model-choices.md" "2023-11-09" +"episodes/modelling-interventions.Rmd" "0c2b8a23920ad50e6cde1bd0eadb0859" "site/built/modelling-interventions.md" "2023-11-09" +"episodes/compare-interventions.Rmd" "78123d2140fbe6488cd295eba3066fcd" "site/built/compare-interventions.md" "2023-11-09" "instructors/instructor-notes.md" "ca3834a1b0f9e70c4702aa7a367a6bb5" "site/built/instructor-notes.md" "2023-10-31" "learners/reference.md" "334277298b83c92dd98c28de895d43cb" "site/built/reference.md" "2023-11-09" "learners/setup.md" "b3c6bfa13fd687f926bb1a3e772a2516" "site/built/setup.md" "2023-10-31" diff --git a/model-choices.md b/model-choices.md index e9273698..cc4ab9ac 100644 --- a/model-choices.md +++ b/model-choices.md @@ -62,7 +62,7 @@ Finally, interventions such as vaccination may be of interest. A model may or ma ### Available models The R package `epidemics` contains functions to run existing models. -For details on the models that are available, see the package [vignettes](https://epiverse-trace.github.io/epidemics/articles). To learn how to run the models in R, read the documentation using `?epidemics::epidemic_ebola`. Remember to use the 'Check model equation' questions to help your understanding of an existing model. +For details on the models that are available, see the package [vignettes](https://epiverse-trace.github.io/epidemics/articles). To learn how to run the models in R, read the documentation using `?epidemics::model_ebola_r`. Remember to use the questions in the '[Check model equation](#check-model-equations)' checklist to help your understanding of an existing model. ::::::::::::::::::::::::::::::::::::: checklist ### Check model equations @@ -85,9 +85,9 @@ You have been asked to explore the variation in numbers of infected individuals Which of the following models would be an appropriate choice for this task: -+ `epidemic_default` ++ `model_default_cpp()` -+ `epidemic_ebola` ++ `model_ebola_r()` ::::::::::::::::: hint @@ -118,23 +118,21 @@ Consider the following questions: + What is the outcome of interest? **Number of infections** + Will any interventions be modelled? **No** -#### `epidemic_default` +#### `model_default_cpp()` A deterministic SEIR model with age specific direct transmission. - - + The model is capable of predicting an Ebola type outbreak, but as the model is deterministic, we are not able to explore stochastic variation in the early stages of the outbreak. -#### `epidemic_ebola` +#### `model_ebola_r()` A stochastic SEIHFR (Susceptible, Exposed, Infectious, Hospitalised, Funeral, Removed) model that was developed specifically for infection with Ebola. - - + diff --git a/modelling-interventions.md b/modelling-interventions.md index 7a82be3f..2fb40769 100644 --- a/modelling-interventions.md +++ b/modelling-interventions.md @@ -54,7 +54,7 @@ In mathematical modelling, we must make assumptions about how NPIs will affect t We want to investigate the effect of school closures on reducing the number of individuals infectious with COVID-19 through time. We assume that a school closure will reduce the frequency of contacts within and between different age groups. -Using an SEIR model (`epidemic_default()` in the R package `{epidemics}`) we set $R_0 = 2.7$, preinfectious period $= 4$ and the infectious_period $= 5.5$ (parameters adapted from [Davies et al. (2020)](https://doi.org/10.1016/S2468-2667(20)30133-X)). We load a contact matrix with age bins 0-18, 18-65, 65 years and older using `{socialmixr}` and assume that one in every 1 million in each age group is infectious at the start of the epidemic. +Using an SEIR model (`model_default_cpp()` in the R package `{epidemics}`) we set $R_0 = 2.7$, preinfectious period $= 4$ and the infectious_period $= 5.5$ (parameters adapted from [Davies et al. (2020)](https://doi.org/10.1016/S2468-2667(20)30133-X)). We load a contact matrix with age bins 0-18, 18-65, 65 years and older using `{socialmixr}` and assume that one in every 1 million in each age group is infectious at the start of the epidemic. We will assume that school closures will reduce the contacts between school aged children (aged 0-15) by 0.5, and will cause a small reduction (0.01) in the contacts between adults (aged 15 and over). @@ -108,16 +108,13 @@ close_schools <- intervention( ``` -```{.error} -Error in epidemic_default_cpp(population = uk_population, infection = covid, : could not find function "epidemic_default_cpp" -``` To run the model with an intervention we set ` intervention = list(contacts = close_schools)` as follows: ```r -output_school <- epidemic_default_cpp( +output_school <- model_default_cpp( population = uk_population, infection = covid, intervention = list(contacts = close_schools), @@ -125,17 +122,10 @@ output_school <- epidemic_default_cpp( ) ``` -```{.error} -Error in epidemic_default_cpp(population = uk_population, infection = covid, : could not find function "epidemic_default_cpp" -``` - We see that with the intervention (solid line) in place, the infection still spreads through the population, though the epidemic peak is smaller than the baseline with no intervention in place (dashed line). - -```{.error} -Error in eval(expr, envir, enclos): object 'output_school' not found -``` + #### Effect of mask wearing on COVID-19 spread @@ -160,7 +150,7 @@ To implement this intervention on the parameter $\beta$, we specify `interventio ```r -output_masks <- epidemic_default_cpp( +output_masks <- model_default_cpp( population = uk_population, infection = covid, intervention = list(beta = mask_mandate), @@ -168,24 +158,16 @@ output_masks <- epidemic_default_cpp( ) ``` -```{.error} -Error in epidemic_default_cpp(population = uk_population, infection = covid, : could not find function "epidemic_default_cpp" -``` - - -```{.error} -Error in eval(expr, envir, enclos): object 'output_masks' not found -``` + ## Pharmaceutical interventions Models can be used to investigate the effect of pharmaceutical interventions, such as vaccination. In this case, it is useful to add another disease state to track the number of vaccinated individuals through time. The diagram below shows an SEIRV model where susceptible individuals are vaccinated and then move to the $V$ class. - - + The equations describing this model are as follows: @@ -218,7 +200,7 @@ We pass our vaccination object using `vaccination = vaccinate`: ```r -output_vaccinate <- epidemic_default_cpp( +output_vaccinate <- model_default_cpp( population = uk_population, infection = covid, vaccination = vaccinate, @@ -226,16 +208,9 @@ output_vaccinate <- epidemic_default_cpp( ) ``` -```{.error} -Error in epidemic_default_cpp(population = uk_population, infection = covid, : could not find function "epidemic_default_cpp" -``` - Here we see that the total number of infectious individuals when vaccination is in place is much lower compared to school closures and mask wearing interventions. - -```{.error} -Error in eval(expr, envir, enclos): object 'output_vaccinate' not found -``` + ## Summary diff --git a/simulating-transmission.md b/simulating-transmission.md index ebb59a50..d5d2e9f1 100644 --- a/simulating-transmission.md +++ b/simulating-transmission.md @@ -43,14 +43,7 @@ Mathematical models are useful tools for generating future trajectories of disea In this tutorial, we will use the R package `{epidemics}` to generate trajectories of influenza spread. By the end of this tutorial, you will be able to generate the trajectory below showing the number of infectious individuals in different age categories through time. - -```{.error} -Error in epidemic_default_cpp(population = uk_population, infection = influenza, : could not find function "epidemic_default_cpp" -``` - -```{.error} -Error in eval(expr, envir, enclos): object 'output' not found -``` + :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: instructor @@ -71,7 +64,7 @@ pak::pak("epiverse-trace/epidemics") ## Model structures To generate predictions of infectious disease trajectories, we must first select a mathematical model to use. -There is a library of models to choose from in `epidemics`. Models are prefixed with epidemic and suffixed by the infection name. In this tutorial, we will use the default epidemic model, `epidemic_default()` which is described in the next section. +There is a library of models to choose from in `epidemics`. Models are prefixed with `model` and suffixed by the name of infection (e.g. ebola) or a different identifier (e.g. default), and whether the model has a R or C++ code base. In this tutorial, we will use the default epidemic model, `model_default_cpp()` which is described in the next section. ::::::::::::::::::::::::::::::::::::: callout @@ -320,23 +313,22 @@ No we are ready to run our model. We will specify `time_end=600` to run the mode ```r -output <- epidemic_default_cpp( +output <- model_default_cpp( population = uk_population, infection = influenza, time_end = 600 ) -``` - -```{.error} -Error in epidemic_default_cpp(population = uk_population, infection = influenza, : could not find function "epidemic_default_cpp" -``` - -```r head(output) ``` -```{.error} -Error in eval(expr, envir, enclos): object 'output' not found +```{.output} + time demography_group compartment value +1: 0 [0,20) susceptible 14799275 +2: 0 [20,40) susceptible 16526302 +3: 0 40+ susceptible 28961159 +4: 0 [0,20) exposed 0 +5: 0 [20,40) exposed 0 +6: 0 40+ exposed 0 ``` Our model output consists of the number of individuals in each compartment in each age group through time. We can visualise the infectious individuals only (those in the $I$ class) through time. @@ -368,9 +360,7 @@ ggplot(output[compartment == "infectious", ]) + ) ``` -```{.error} -Error in eval(expr, envir, enclos): object 'output' not found -``` + ::::::::::::::::::::::::::::::::::::: callout @@ -412,7 +402,7 @@ output_samples <- Map( ) # run an epidemic model using `epidemic()` - output <- epidemic_default_cpp( + output <- model_default_cpp( population = uk_population, infection = influenza, time_end = 600, increment = 1.0 @@ -427,21 +417,11 @@ output_samples <- Map( output } ) -``` - -```{.error} -Error in epidemic_default_cpp(population = uk_population, infection = influenza, : could not find function "epidemic_default_cpp" -``` -```r # combine to prepare for plotting output_samples <- bind_rows(output_samples) ``` -```{.error} -Error in eval(expr, envir, enclos): object 'output_samples' not found -``` - 3. Calculate the mean and 95% quantiles of number of infectious individuals across each model simulation and visualise output @@ -461,9 +441,7 @@ ggplot(output_samples ,aes(time, value)) + ) ``` -```{.error} -Error in eval(expr, envir, enclos): object 'output_samples' not found -``` + Deciding which parameters to include uncertainty in depends on a few factors: how well informed a parameter value is e.g. consistency of estimates from the literature; how sensitive model outputs are to parameter value changes; and the purpose of the modelling task.