diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index efc58aa6..d973ce73 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -222,8 +222,8 @@ community listed at including via social media, slack, newsletters, and email lists. You can also [reach us by email][contact]. -[repo]: https://github.com/epiverse-trace/tutorials -[repo-issues]: https://github.com/epiverse-trace/tutorials/issues +[repo]: https://github.com/epiverse-trace/tutorials-early +[repo-issues]: https://github.com/epiverse-trace/tutorials-early/issues [contact]: mailto:andree.valle-campos@lshtm.ac.uk [cp-site]: https://epiverse-trace.github.io/ [dc-issues]: https://github.com/issues?q=user%3Adatacarpentry diff --git a/config.yaml b/config.yaml index c62ee29f..7d331214 100644 --- a/config.yaml +++ b/config.yaml @@ -11,13 +11,13 @@ carpentry: 'incubator' # Overall title for pages. -title: 'Outbreak analytics with R' +title: 'Reading and cleaning data for outbreak analytics with R' # Date the lesson was created (YYYY-MM-DD, this is empty by default) created: # Comma-separated list of keywords for the lesson -keywords: 'forecasts, epidemic models, interventions' +keywords: # Life cycle stage of the lesson # possible values: pre-alpha, alpha, beta, stable @@ -27,7 +27,7 @@ life_cycle: 'pre-alpha' license: 'CC-BY 4.0' # Link to the source repository for this lesson -source: 'https://github.com/epiverse-trace/tutorials' +source: 'https://github.com/epiverse-trace/tutorials-early' # Default branch of your lesson branch: 'main' @@ -59,14 +59,7 @@ contact: 'andree.valle-campos@lshtm.ac.uk' # Order of episodes in your lesson episodes: -- introduction.Rmd - read-delays.Rmd -- quantify-transmissibility.Rmd -- create-forecast.Rmd -- simulating-transmission.Rmd -- model-choices.Rmd -- modelling-interventions.Rmd -- compare-interventions.Rmd # Information for Learners learners: @@ -84,4 +77,4 @@ profiles: varnish: epiverse-trace/varnish@epiversetheme # this is carpentries/sandpaper#533 in our fork so we can keep it up to date with main -sandpaper: epiverse-trace/sandpaper@patch-renv-github-bug +sandpaper: epiverse-trace/sandpaper@patch-renv-github-bug diff --git a/episodes/compare-interventions.Rmd b/episodes/compare-interventions.Rmd deleted file mode 100644 index 419379da..00000000 --- a/episodes/compare-interventions.Rmd +++ /dev/null @@ -1,275 +0,0 @@ ---- -title: 'Comparing public health outcomes of interventions' -teaching: 45 # teaching time in minutes -exercises: 30 # exercise time in minutes - ---- - -:::::::::::::::::::::::::::::::::::::: questions - -- How can I quantify the effect of an intervention? - - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: objectives - -- Compare intervention scenarios - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: prereq - -## Prerequisites -+ Complete tutorials [Simulating transmission](../episodes/simulating-transmission.md) and [Modelling interventions](../episodes/modelling-interventions.md) - -Learners should familiarise themselves with following concept dependencies before working through this tutorial: - -**Outbreak response** : [Intervention types](https://www.cdc.gov/nonpharmaceutical-interventions/). -::::::::::::::::::::::::::::::::: - - -## Introduction - -In this tutorial we will compare intervention scenarios against each other. To quantify the effect of the intervention we need to compare our intervention scenario to a counter factual scenario. The *counter factual* is the scenario in which nothing changes, often referred to as the 'do nothing' scenario. The counter factual scenario may include no interventions, or if we are investigating the potential impact of an additional intervention in the later stages of an outbreak there may be existing interventions in place. - -We must also decide what our *outcome of interest* is to make comparisons between intervention and counter factual scenarios. The outcome of interest can be: - -+ a model outcome, e.g. number of infections or hospitalisations, -+ a metric such as the epidemic peak time or size, -+ a measure that uses the model outcomes such as QALY/DALYs. - - -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: instructor - -In this tutorial we introduce the concept of the counter factual and how to compare scenarios (counter factual versus intervention) against each other. - -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -## Vacamole model - -The Vacamole model is a deterministic model based on a system of ODEs in [Ainslie et al. 2022]( https://doi.org/10.2807/1560-7917.ES.2022.27.44.2101090) to describe the effect of vaccination on COVID-19 dynamics. The model consists of 11 compartments, individuals are classed as one of the following: - -+ susceptible, $S$, -+ partial vaccination ($V_1$), fully vaccination ($V_2$), -+ exposed, $E$ and exposed while vaccinated, $E_V$, -+ infectious, $I$ and infectious while vaccinated, $I_V$, -+ hospitalised, $H$ and hospitalised while vaccinated, $H_V$, -+ dead, $D$, -+ recovered, $R$. - -The diagram below describes the flow of individuals through the different compartments. - -```{r, echo = FALSE, message = FALSE} -DiagrammeR::grViz("digraph{ - # graph statement - ################# - graph [layout = dot, - rankdir = LR, - overlap = true, - fontsize = 10] - - # nodes - ####### - node [shape = square, - fixedsize = true - width = 1.3] - - S - E - Ev [label = 'E@_{V}', style = filled, fillcolour = 'gray'] - I - Iv [label = 'I@_{V}', style = filled, fillcolour = 'gray'] - H - Hv [label = 'H@_{V}', style = filled, fillcolour = 'gray'] - D - R - V1 [label = 'V@_{1}', style = filled, fillcolour = 'gray'] - V2 [label = 'V@_{2}', style = filled, fillcolour = 'gray'] - - - # edges - ####### - S -> E [label = ' infection (β) '] - S -> V1 [label = ' vaccination (ν1)'] - V1 -> E [label = ' infection (β)'] - V1 -> V2 [label = ' vaccination\n(second dose) (ν2)'] - V2 -> Ev [label = ' infection (β)'] - Ev -> Iv [label = ' onset of \ninfectiousness (α) '] - E -> I [label = ' onset of \ninfectiousness (α) '] - I -> H [label = ' hospitalisation (η)'] - Iv -> Hv [label = ' hospitalisation (η@_{V})'] - I -> D [label = ' death (ω)'] - I -> R [label = ' recovery (γ)'] - Iv -> D [label = ' death (ω@_{V})'] - Iv -> R [label = ' recovery (γ)'] - Hv -> D [label = ' death (ω@_{V})'] - Hv -> R [label = ' recovery (γ)'] - H -> D [label = ' death (ω)'] - H -> R [label = ' recovery (γ)'] - - subgraph { - rank = same; S; V1;V2; - } -}") -``` - - -::::::::::::::::::::::::::::::::::::: challenge - -## Running a counterfactual scenario using the Vacamole model - -1. Run the model with the default parameter values for the UK population assuming that : - -+ 1 in a million individual are infectious (and not vaccinated) at the start of the simulation -+ The contact matrix for the United Kingdom has age bins: - + age between 0 and 20 years, - + age between 20 and 40, - + 40 years and over. -+ There is no vaccination scheme in place - -2. Using the output, plot the number of deaths through time - - -::::::::::::::::: hint - -### Vaccination code - -To run the model with no vaccination in place we can *either* create two vaccination objects (one for each dose) using `vaccination()` with the time start, time end and vaccination rate all set to 0, or we can use the `no_vaccination()` function to create a vaccination object for two doses with all values set to 0. - -```{r, eval = FALSE} -no_vaccination <- no_vaccination(population = uk_population, doses = 2) -``` -:::::::::::::::::::::: - -::::::::::::::::: hint - -### HINT : Running the model with default parameter values - -We can run the Vacamole model with [default parameter values](https://epiverse-trace.github.io/epidemics/articles/vacamole.html#model-epidemic-using-vacamole) by just specifying the population object and number of time steps to run the model for: - - -```{r, eval = FALSE} -output <- model_vacamole_cpp( - population = uk_population, - vaccination = no_vaccination, - time_end = 300 -) -``` - -:::::::::::::::::::::: - - - -::::::::::::::::: solution - -### SOLUTION - -1. Run the model - -```{r} -polymod <- socialmixr::polymod -contact_data <- socialmixr::contact_matrix( - survey = polymod, - countries = "United Kingdom", - age.limits = c(0, 20, 40), - symmetric = TRUE -) -# prepare contact matrix -contact_matrix <- t(contact_data$matrix) - -# extract demography vector -demography_vector <- contact_data$demography$population -names(demography_vector) <- rownames(contact_matrix) - -# prepare initial conditions -initial_i <- 1e-6 - -initial_conditions <- c( - S = 1 - initial_i, - V1 = 0, V2 = 0, - E = 0, EV = 0, - I = initial_i, IV = 0, - H = 0, HV = 0, D = 0, R = 0 -) - -initial_conditions <- rbind( - initial_conditions, - initial_conditions, - initial_conditions -) -rownames(initial_conditions) <- rownames(contact_matrix) - -# prepare population object -uk_population <- population( - name = "UK", - contact_matrix = contact_matrix, - demography_vector = demography_vector, - initial_conditions = initial_conditions -) - -no_vaccination <- no_vaccination(population = uk_population, doses = 2) - -# run model -output <- model_vacamole_cpp( - population = uk_population, - vaccination = no_vaccination, - time_end = 300 -) -``` - -2. Plot the number of deaths through time - -```{r} -ggplot(output[output$compartment == "dead", ]) + - geom_line( - aes(time, value, colour = demography_group), - linewidth = 1 - ) + - scale_colour_brewer( - palette = "Dark2", - labels = rownames(contact_matrix), - name = "Age group" - ) + - scale_y_continuous( - labels = scales::comma - ) + - labs( - x = "Simulation time (days)", - y = "Individuals" - ) + - theme( - legend.position = "top" - ) + - theme_bw( - base_size = 15 - ) -``` - - - -::::::::::::::::::::::::::: - - -:::::::::::::::::::::::::::::::::::::::::::::::: - - - -## Comparing scenarios - -*Coming soon* - - - -## Challenge : Ebola outbreak analysis - -*Coming soon* - - - - -::::::::::::::::::::::::::::::::::::: keypoints - -- The counter factual scenario must be defined to make comparisons - -:::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/episodes/create-forecast.Rmd b/episodes/create-forecast.Rmd deleted file mode 100644 index 48c85e5f..00000000 --- a/episodes/create-forecast.Rmd +++ /dev/null @@ -1,348 +0,0 @@ ---- -title: 'Create a short-term forecast' -teaching: 30 -exercises: 30 -editor_options: - chunk_output_type: inline ---- - -```{r setup, echo = FALSE, warning = FALSE, message = FALSE} -library(EpiNow2) -withr::local_options(list(mc.cores = 4)) -``` - - -:::::::::::::::::::::::::::::::::::::: questions - -- How do I create short-term forecasts from case data? -- How do I account for incomplete reporting in forecasts? - - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: objectives - -- Learn how to make forecasts of cases using R package `EpiNow2` -- Learn how to include an observation process in estimation - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: prereq - -## Prerequisites - -+ Complete tutorial [Quantifying transmission](../episodes/quantify-transmissibility.md) - -Learners should familiarise themselves with following concept dependencies before working through this tutorial: - -**Statistics** : probability distributions, principle of Bayesian analysis. - -**Epidemic theory** : Effective reproduction number. - -::::::::::::::::::::::::::::::::: - -## Introduction - -Given case data, we can create estimates of the current and future number of cases by accounting for both delays in reporting and under reporting. To make statements about the future, we need to make an assumption of how observations up to today are related to what we expect to happen in the future. The simplest way of doing so is to assume "no change", i.e. the reproduction number remains the same in the future as last observed. In this tutorial we will create short-term forecasts by assuming the reproduction number will remain the same as it was estimated to be on the final date for which data was available. - -## Create a short-term forecast - -The function `epinow()` described in the previous tutorial is a wrapper for the function `estimate_infections()` used to estimate cases by date of infection. Using the same code in the previous tutorial we can extract the short-term forecast using: - -```{r, echo = FALSE} -cases <- aggregate( - cases_new ~ date, - data = incidence2::covidregionaldataUK[, c("date", "cases_new")], - FUN = sum -) -colnames(cases) <- c("date", "confirm") -rt_log_mean <- convert_to_logmean(2, 1) -rt_log_sd <- convert_to_logsd(2, 1) - -incubation_period_fixed <- dist_spec( - mean = 4, sd = 2, - max = 20, distribution = "gamma" -) - -log_mean <- convert_to_logmean(2, 1) -log_sd <- convert_to_logsd(2, 1) -reporting_delay_fixed <- dist_spec( - mean = log_mean, sd = log_sd, - max = 10, distribution = "lognormal" -) - -generation_time_fixed <- dist_spec( - mean = 3.6, sd = 3.1, - max = 20, distribution = "lognormal" -) -``` - - -```{r, message = FALSE, eval = TRUE} -reported_cases <- cases[1:90, ] -estimates <- epinow( - reported_cases = reported_cases, - generation_time = generation_time_opts(generation_time_fixed), - delays = delay_opts(incubation_period_fixed + reporting_delay_fixed), - rt = rt_opts(prior = list(mean = rt_log_mean, sd = rt_log_sd)) -) -``` - - -We can visualise the estimates of the effective reproduction number and the estimated number of cases using `plot()`. The estimates are split into three categories: - -+ **Estimate** (green): utilises all data, - -+ **Estimate based on partial data** (orange): estimates that are based less data are therefore more uncertain, - -+ **Forecast** (purple): forecasts into the future. - - -```{r} -plot(estimates) -``` - - -::::::::::::::::::::::::::::::::::::: callout -### Forecasting with estimates of $R_t$ - -By default, the short-term forecasts are created using the latest estimate of the reproduction number $R_t$. As this estimate is based on partial data, it has considerable uncertainty. - -The reproduction number that is projected into the future can be changed to a less recent estimate based on more data using `rt_opts()`: - -```{r, eval = FALSE} -rt_opts(future = "estimate") -``` - -The result will be less uncertain forecasts (as they are based on $R_t$ with a narrower uncertainty interval) but the forecasts will be based on less recent estimates of $R_t$ and assume no change since then. - -Additionally, there is the option to project the value of $R_t$ into the future using a generic model by setting `future = "project"`. As this option uses a model to forecast the value of $R_t$, the result will be forecasts that are more uncertain than `estimate`, for an example [see here](https://epiforecasts.io/EpiNow2/dev/articles/estimate_infections_options.html#projecting-the-reproduction-number-with-the-gaussian-process). - -:::::::::::::::::::::::::::::::::::::::::::::::: - - -### Incomplete observations - -In the previous tutorial we accounted for delays in reporting. In `EpiNow2` we also can account for incomplete observations as in reality, 100% of cases are not reported. - -We will pass another input into `epinow()` called `obs` to define an observation model. The format of `obs` must be the `obs_opt()` function (see `?EpiNow2::obs_opts` for more detail). - -Let's say we believe the COVID-19 outbreak data from the previous tutorial do not include all reported cases. We believe that we only observe 40% of cases. To specify this in the observation model, we must pass a scaling factor with a mean and standard deviation. If we assume that 40% of cases are in the case data (with standard deviation 1%), then we specify the `scale` input to `obs_opts()` as follows: - -```{r} -obs_scale <- list(mean = 0.4, sd = 0.01) -``` - -To run the inference framework with this observation process, we add `obs = obs_opts(scale = obs_scale)` to the input arguments of `epinow()`: - -```{r, message = FALSE, eval = TRUE} -obs_scale <- list(mean = 0.4, sd = 0.01) -reported_cases <- cases[1:90, ] -estimates <- epinow( - reported_cases = reported_cases, - generation_time = generation_time_opts(generation_time_fixed), - delays = delay_opts(incubation_period_fixed + reporting_delay_fixed), - rt = rt_opts(prior = list(mean = rt_log_mean, sd = rt_log_sd)), - obs = obs_opts(scale = obs_scale) -) -summary(estimates) -``` - - -The estimates of transmission measures such as the effective reproduction number and rate of growth are similar (or the same in value) compared to when we didn't account for incomplete observations (see previous tutorial). However the number of new confirmed cases by infection date has changed substantially in magnitude to reflect the assumption that only 40% of cases are in the data set. - -We can also change the default distribution from Negative Binomial to Poisson, remove the default week effect and more. See `?EpiNow2::obs_opts` for more detail. - - -## Forecast secondary observations - -`EpiNow2` also has the ability to estimate and forecast secondary observations e.g. deaths, hospitalisations from a primary observation e.g. cases. Here we will illustrate how to forecast the number of deaths arising from observed cases of COVID-19 in the early stages of the UK outbreak. - -First, we must format our data to have the following columns: - -+ `date` : the date (as a date object see `?is.Date()`), -+ `primary` : number of primary observations on that date, in this example **cases**, -+ `secondary` : number of secondary observations date, in this example **deaths**. - -```{r} -reported_cases_deaths <- aggregate( - cbind(cases_new, deaths_new) ~ date, - data = - incidence2::covidregionaldataUK[, c("date", "cases_new", "deaths_new")], - FUN = sum -) -colnames(reported_cases_deaths) <- c("date", "primary", "secondary") -``` - - -Using the first 30 days of data on cases and deaths, we will estimate the relationship between the primary and secondary observations using `estimate_secondary()`, then forecast future deaths using `forecast_secondary()`. For detail on the model see the [model documentation](https://epiforecasts.io/EpiNow2/dev/articles/estimate_secondary.html). - -We must specify the type of observation using `type` in `secondary_opts()`, options include: - -+ "incidence" : secondary observations arise from previous primary observations, i.e. deaths arising from recorded cases. -+ "prevalence" : secondary observations arise from a combination current primary observations and past secondary observations, i.e. hospital bed usage arising from current hospital admissions and past hospital bed usage. - -In this example we specify `secondary_opts(type = "incidence")`. See `?EpiNow2::secondary_opts` for more detail). - -The final key input is the delay distribution between the primary and secondary observations. Here this is the delay between case report and death, we assume this follows a gamma distribution with mean of 14 days and standard deviation of 5 days. Using `dist_spec()` we specify a fixed gamma distribution. - -There are further function inputs to `estimate_secondary()` which can be specified, including adding an observation process, see `?EpiNow2::estimate_secondary` for detail on the options. - -To find the model fit between cases and deaths : -```{r} -estimate_cases_to_deaths <- estimate_secondary( - reports = reported_cases_deaths[1:30, ], - secondary = secondary_opts(type = "incidence"), - delays = delay_opts(dist_spec( - mean = 14, sd = 5, - max = 30, distribution = "gamma" - )) -) -``` - - -::::::::::::::::::::::::::::::::::::: callout -### Be cautious of timescale - -In the early stages of an outbreak there can be substantial changes in testing and reporting. If there are testing changes from one month to another, then there will be a bias in the model fit. Therefore, you should be cautious of the time-scale of data used in the model fit and forecast. - -:::::::::::::::::::::::::::::::::::::::::::::::: - -We plot the model fit (shaded ribbons) with the secondary observations (bar plot) and primary observations (dotted line) as follows: - -```{r} -plot(estimate_cases_to_deaths, primary = TRUE) -``` - -To use this model fit to forecast deaths, we pass a data frame consisting of the primary observation (cases) for dates not used in the model fit. - -*Note : in this tutorial we are using data where we know the deaths and cases, so we create a data frame by extracting the cases. But in practice, this would be a different data set consisting of cases only.* -```{r} -cases_to_forecast <- reported_cases_deaths[31:60, c("date", "primary")] -colnames(cases_to_forecast) <- c("date", "value") -``` - -To forecast, we use the model fit `estimate_cases_to_deaths`: - -```{r} -deaths_forecast <- forecast_secondary( - estimate = estimate_cases_to_deaths, - primary = cases_to_forecast -) -plot(deaths_forecast) -``` - -The plot shows the forecast secondary observations (deaths) over the dates which we have recorded cases for. -It is also possible to forecast deaths using forecast cases, here you would specify `primary` as the `estimates` output from `estimate_infections()`. - - -## Challenge : Ebola outbreak analysis - -::::::::::::::::::::::::::::::::::::: challenge - -Download the file [ebola_cases.csv](data/ebola_cases.csv) and read it into R. The simulated data consists of the date of symptom onset and number of confirmed cases of the early stages of the Ebola outbreak in Sierra Leone in 2014. - -Using the first 3 months (120 days) of data: - -1. Estimate of cases increasing or decreasing on day 120 of the outbreak (Hint: Find the effective reproduction number and growth rate on day 120) -2. Create a two week forecast of number of cases - -You can use the following parameter values for the delay distribution(s) and generation time distribution. - -+ Incubation period : Log normal$(2.487,0.330)$ ([Eichner et al. 2011](https://doi.org/10.1016/j.phrp.2011.04.001) via `{epiparameter}`) -+ Generation time : Gamma$(15.3, 10.1)$ ([WHO Ebola Response Team 2014](https://www.nejm.org/doi/full/10.1056/NEJMoa1411100)) - -You may include some uncertainty around the mean and standard deviation of these distributions. - -::::::::::::::::: hint - -### HINT : data format - -Ensure the data is in the correct format : - -+ `date` : the date (as a date object see `?is.Date()`), -+ `confirm` : number of confirmed cases on that date. - - -:::::::::::::::::::::: - - -::::::::::::::::: solution - -### SOLUTION - -To estimate the effective reproduction number and growth rate, we will use the function `epinow()`. - -As the data consists of date of symptom onset, we only need to specify a delay distribution for the incubation period and the generation time. - -We specify the distributions with some uncertainty around the mean and standard deviation of the log normal distribution for the incubation period and the Gamma distribution for the generation time. - -```{r,eval=TRUE,echo=TRUE} -ebola_incubation_period <- dist_spec( - mean = 2.487, sd = 0.330, - mean_sd = 0.5, sd_sd = 0.5, - max = 20, distribution = "lognormal" -) - -ebola_generation_time <- dist_spec( - mean = 15.3, sd = 10.1, - mean_sd = 0.5, sd_sd = 0.5, - max = 30, distribution = "gamma" -) -``` - -As we want to also create a two week forecast, we specify `horizon = 14` to forecast 14 days instead of the default 7 days. - -```{r, eval=TRUE,echo=FALSE} -# read data from the tutorial repository R project -ebola_cases <- - read.csv(file.path("data", "ebola_cases.csv")) -``` - -```{r,eval=FALSE,echo=TRUE} -# read data -# e.g.: if path to file is data/raw-data/ebola_cases.csv then: -ebola_cases <- - read.csv(here::here("data", "raw-data", "ebola_cases.csv")) -``` - -```{r,eval=TRUE,echo=TRUE, message = FALSE} -# format date column -ebola_cases$date <- as.Date(ebola_cases$date) - -ebola_estimates <- epinow( - reported_cases = ebola_cases[1:120, ], # first 3 months of data only - generation_time = generation_time_opts(ebola_generation_time), - delays = delay_opts(ebola_incubation_period), - # horizon needs to be 14 days to create two week forecast (default is 7 days) - horizon = 14 -) - -summary(ebola_estimates) -``` - -The effective reproduction number $R_t$ estimate (on the last date of the data) is `r summary(ebola_estimates)[measure=="Effective reproduction no."]$estimate`. The exponential growth rate of case numbers is `r summary(ebola_estimates)[measure=="Rate of growth"]$estimate`. - -Visualize the estimates: - -```{r,eval=FALSE,echo=TRUE} -plot(ebola_estimates) -``` - -::::::::::::::::::::::::::: - - -:::::::::::::::::::::::::::::::::::::::::::::::: - -## Summary - -`EpiNow2` can be used to create short term forecasts and to estimate the relationship between different outcomes. There are a range of model options that can be implemented for different analysis, including adding an observational process to account for incomplete reporting. See the [vignette](https://epiforecasts.io/EpiNow2/dev/articles/estimate_infections_options.html) for more details on different model options in `EpiNow2` that aren't covered in these tutorials. - - -::::::::::::::::::::::::::::::::::::: keypoints - -- We can create short-term forecasts by making assumptions about the future behaviour of the reproduction number -- Incomplete case reporting can be accounted for in estimates - - -:::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/episodes/introduction.Rmd b/episodes/introduction.Rmd deleted file mode 100644 index bf059f68..00000000 --- a/episodes/introduction.Rmd +++ /dev/null @@ -1,179 +0,0 @@ ---- -title: 'Outbreak analytics pipelines' -teaching: 10 -exercises: 2 -editor_options: - chunk_output_type: console ---- - -:::::::::::::::::::::::::::::::::::::: questions - -- Why use R packages for Outbreak analytics? -- What can we do to analyse our outbreak data? -- How can I start doing Outbreak Analytics with R? - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: objectives - -- Explain our vision on the need for outbreak analytics R packages. -- Share our strategy to create R packages into an outbreak analytics pipeline. -- Define our plan to start your learning path in outbreak analytics with R. - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: prereq - -## Prerequisites - -This episode requires you to be familiar with: - -**Data science** : Basic programming with R. - -**Epidemic theory** : Reproduction number. - -::::::::::::::::::::::::::::::::: - -## Why to use R packages for Outbreak analytics? - -Outbreaks appear with different diseases and in different contexts, but what all of them have in common are the key public health questions ([Cori et al. 2017](https://royalsocietypublishing.org/doi/10.1098/rstb.2016.0371#d1e605)). - -Is the epidemic going to take off? Is it under control? How much effort will be needed to control it? We can answer them by _quantifying the transmissibility_ of the disease. The most used parameter for this is the reproduction number ($R$), the average number of secondary infections caused by a typical primary case in the population -of interest ([Prism, 2016](http://prism.edu.au/publications/prism-modeling-guideline/)). We can intuitively interpret it as: - -- if $R>1$, the epidemic is likely to grow, -- if $R<1$, the epidemic is likely to decline. - -We can estimate the reproduction number by initially using two __data inputs__: the incidence of reported cases and the [generation time](../learners/reference.md#generationtime) distribution. But to calculate it, we must apply the appropriate mathematical models written in code with the required computational methods. That is not enough! Following _good practices_, the code we write should be peer-reviewed and contain internal tests to double-check that we are getting the estimates we expect. Imagine rewriting all of it during a health emergency! - -In R, the fundamental unit of shareable code is the _package_. A package bundles together code, data, documentation, and tests and is easy to share with others ([Wickham and Bryan, 2023](https://r-pkgs.org/introduction.html)). We, as epidemiologists, can contribute to their collaborative maintenance as a community to perform less error-prone data analysis pipelines. - -::::::::::::::::::::::::::::::::: discussion - -### Questions to think about - -Remember your last experience with outbreak data and reflect on these questions: - -- What data sources did you need to understand the outbreak? -- How did you get access to that data? -- Is that analysis pipeline you followed reusable for the next response? - -Reflect on your experiences. - -::::::::::::::::::::::::::::::::::::::::::: - - -## Example: Quantify transmission - -The `{EpiNow2}` package provides a three-step solution to _quantify the transmissibility_. Let's see how to do this with a minimal example. First, load the package: - -```{r,warning=FALSE} -library(EpiNow2) -``` - -### First, get your case data - -Case incidence data must be stored in a data frame with the observed number of cases per day. We can read an example from the package: - -```{r} -example_confirmed -``` - -### Then, set the generation time - -Not all primary cases have the same probability of generating a secondary case. The onset and cessation of [infectiousness](../learners/reference.md#infectiousness) may occur gradually. For `{EpiNow2}`, we can specify it as a probability `distribution` with `mean`, standard deviation `sd`, and maximum value `max`: - -```{r} -generation_time <- dist_spec( - mean = 3.6, - sd = 3.1, - max = 20, - distribution = "lognormal" -) -``` - -### Let's calculate the reproduction number! - -In the `epinow()` function we can add: - -- the `reported_cases` data frame, -- the `generation_time` delay distribution, and -- the computation `stan` parameters for this calculation: - -```{r,message=FALSE,warning=FALSE} -epinow_estimates <- epinow( - # cases - reported_cases = example_confirmed[1:60], - # delays - generation_time = generation_time_opts(generation_time), - # computation - stan = stan_opts( - cores = 4, samples = 1000, chains = 3, - control = list(adapt_delta = 0.99) - ) -) -``` - -As an output, we get the time-varying (or [effective](../learners/reference.md#effectiverepro)) reproduction number, as well as the cases by date of report and date of infection: - -```{r} -base::plot(epinow_estimates) -``` - -::::::::::::::::: callout - -### Is this $Rt$ estimation biased? - -Review [Gostic et al., 2020](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1008409) about what additional adjustments this estimation requires to avoid false precision in $Rt$. - -::::::::::::::::::::::::: - -## The problem! - -However, _quantifying the transmissibility_ during a real-life outbreak response is more challenging than this example! - -Usually, we receive outbreak data in non-standard formats, requiring specific steps and taking the most time to prepare usable data inputs. Some of them are: - -- Read delay distributions from the literature -- Read and clean case data -- Validate your line list -- Describe case data - -And this is not the end. After _quantifying transmissibility_ we need to answer more key public health questions like: What is the attack rate we expect? What would be the impact of a given intervention? We can use the reproduction number and other outputs as new inputs for complementary tasks. For example: - -- Estimate severity -- Create short-term forecast -- Simulate transmission scenarios -- Compare interventions - -So, all these tasks can be interconnected in a pipeline: - -![The outbreak analytics pipeline.](https://epiverse-trace.github.io/task_pipeline-minimal.svg) - -## What can we do? - -Our strategy is gradually incorporating specialised R packages into our traditional analysis pipeline. These packages should fill the gaps in these epidemiology-specific tasks in response to outbreaks. - -Epiverse-TRACE's aim is to provide a software ecosystem for outbreak analytics. We support the development of software pieces, make the existing ones interoperable for the user experience, and stimulate a community of practice. - -![](fig/pkgs-hexlogos.png) - -## How can I start? - -Our plan for these tutorials is to introduce key solutions from packages in all the tasks before and after the _Quantify transmission_ task, plus the required theory concepts to interpret modelling outputs and make rigorous conclusions. - -- In the first set of episodes, you will learn how to optimise the reading of delay distributions and cleaning of case data to input them into the _Quantify transmission_ task. These preliminary tasks are the __Early tasks__. These include packages like `{readepi}`, `{cleanepi}`, `{linelist}`, `{epiparameter}`, and `{episoap}`. - -- Then, we will get deeper into the packages and required theory to _Quantify transmission_ and perform more real-time analysis tasks next to it. These are the __Middle tasks__. This includes `{EpiNow2}`, `{cfr}`, `{epichains}`, and `{superspreading}`. - -- Lastly, we will use _Quantify transmission_ data outputs to compare it to other indicators and simulate epidemic scenarios as part of the __Late tasks__. This includes `{finalsize}`, `{epidemics}`, and `{scenarios}`. - - -::::::::::::::::::::::::::::::::::::: keypoints - -- Our vision is to have pipelines of R packages for outbreak analytics. -- Our strategy is to create interconnected tasks to get relevant outputs for public health questions. -- We plan to introduce package solutions and theory bits for each of the tasks in the outbreak analytics pipeline. - -:::::::::::::::::::::::::::::::::::::::::::::::: - diff --git a/episodes/model-choices.Rmd b/episodes/model-choices.Rmd deleted file mode 100644 index 4a60e366..00000000 --- a/episodes/model-choices.Rmd +++ /dev/null @@ -1,418 +0,0 @@ ---- -title: 'Choosing an appropriate model' -teaching: 10 # teaching time in minutes -exercises: 20 # exercise time in minutes - ---- - -```{r setup, echo = FALSE, message = FALSE, warning = FALSE} -library(epidemics) -library(dplyr) -library(ggplot2) -``` - -:::::::::::::::::::::::::::::::::::::: questions - -- How do I choose a mathematical model that's appropriate to complete my analytical task? - - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: objectives - -- Understand the model requirements for a specific research question - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: prereq - -## Prerequisites -+ Complete tutorial [Simulating transmission](../episodes/simulating-transmission.md) -::::::::::::::::::::::::::::::::: - - -## Introduction - -There are existing mathematical models for different infections, interventions and transmission patterns which can be used to answer new questions. In this tutorial, we will learn how to choose an existing model to complete a given task. - -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: instructor - -The focus of this tutorial is understanding existing models to decide if they are appropriate for a defined question. - -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::::: discussion - -### Choosing a model - -When deciding which mathematical model to use, there are a number of questions we must consider : - -::::::::::::::::::::::::::::::::::::::::::::::::::: - -:::::::::::::::: solution - -### What is the infection/disease of interest? - -A model may already exist for your study disease, or there may be a model for an infection that has the same transmission pathways and epidemiological features that can be used. - -::::::::::::::::::::::::: - -:::::::::::::::: solution - -### Do we need a [deterministic](../learners/reference.md#deterministic) or [stochastic](../learners/reference.md#stochastic) model? - -Model structures differ for whether the disease has pandemic potential or not. When predicted numbers of infection are small, stochastic variation in output can have an effect on whether an outbreak takes off or not. Outbreaks are usually smaller in magnitude than epidemics, so its often appropriate to use a stochastic model to characterise the uncertainty in the early stages of the outbreak. Epidemics are larger in magnitude than outbreaks and so a deterministic model is suitable as we have less interest in the stochastic variation in output. - -::::::::::::::::::::::::: - -:::::::::::::::: solution - -## What is the outcome of interest? - -The outcome of interest can be a feature of a mathematical model. It may be that you are interested in the predicted numbers of infection through time, or in a specific outcome such as hospitalisations or cases of severe disease. - -::::::::::::::::::::::::: - -:::::::::::::::: solution - -## How is transmission modelled? - -For example, [direct](../learners/reference.md#direct) or [indirect](../learners/reference.md#indirect), [airborne](../learners/reference.md#airborne) or [vector-borne](../learners/reference.md#vectorborne). -::::::::::::::::::::::::: - - -:::::::::::::::: solution - -## How are the different processes (e.g. transmission) formulated in the equations? - -There can be subtle differences in model structures for the same infection or outbreak type which can be missed without studying the equations. For example, transmissibility parameters can be specified as rates or probabilities. If you want to use parameter values from other published models, you must check that transmission is formulated in the same way. -::::::::::::::::::::::::: - -:::::::::::::::: solution - -## Will any interventions be modelled? - -Finally, interventions such as vaccination may be of interest. A model may or may not have the capability to include the impact of different interventions on different time scales (continuous time or at discrete time points). We discuss interventions in detail in the tutorial [Modelling interventions](../episodes/modelling-interventions.md). - -::::::::::::::::::::::::: - - - - - - -## Available models in `epidemics` - -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::model_ebola_r`. - - -::::::::::::::::::::::::::::::::::::: challenge - -## What model? - -You have been asked to explore the variation in numbers of infectious individuals in the early stages of an Ebola outbreak. - -Which of the following models would be an appropriate choice for this task: - -+ `model_default_cpp()` - -+ `model_ebola_r()` - -::::::::::::::::: hint - -### HINT - -Consider the following questions: - -::::::::::::::::::::::::::::::::::::: checklist - -+ What is the infection/disease of interest? -+ Do we need a deterministic or stochastic model? -+ What is the outcome of interest? -+ Will any interventions be modelled? - -:::::::::::::::::::::::::::::::::::::::::::::::: - - -:::::::::::::::::::::: - - -::::::::::::::::: solution - -### SOLUTION - - -+ What is the infection/disease of interest? **Ebola** -+ Do we need a deterministic or stochastic model? **A stochastic model would allow us to explore variation in the early stages of the outbreak** -+ What is the outcome of interest? **Number of infections** -+ Will any interventions be modelled? **No** - -#### `model_default_cpp()` - -A deterministic SEIR model with age specific direct transmission. - -```{r diagram, echo = FALSE, message = FALSE} -DiagrammeR::grViz("digraph { - - # graph statement - ################# - graph [layout = dot, - rankdir = LR, - overlap = true, - fontsize = 10] - - # nodes - ####### - node [shape = square, - fixedsize = true - width = 1.3] - - S - E - I - R - - # edges - ####### - S -> E [label = ' infection \n(transmissibility β)'] - E -> I [label = ' onset of infectiousness \n(infectiousness rate α)'] - I -> R [label = ' recovery \n(recovery rate γ)'] - -}") -``` - - -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. - - -#### `model_ebola_r()` - -A stochastic SEIHFR (Susceptible, Exposed, Infectious, Hospitalised, Funeral, Removed) model that was developed specifically for infection with Ebola. The model has stochasticity in the passage times between states, which are modelled as Erlang distributions. - -The key parameters affecting the transition between states are: - -+ $R_0$, the basic reproduction number, -+ $\rho^I$, the mean infectious period, -+ $\rho^E$, the mean preinfectious period, -+ $p_{hosp}$ the probability of being transferred to the hospitalised compartment. - -**Note: the functional relationship between the preinfectious period ($\rho^E$) and the transition rate between exposed and infectious ($\gamma^E$) is $\rho^E = k^E/\gamma^E$ where $k^E$ is the shape of the Erlang distribution. Similarly for the infectious period $\rho^I = k^I/\gamma^I$. See [here](https://epiverse-trace.github.io/epidemics/articles/ebola_model.html#details-discrete-time-ebola-virus-disease-model) for more detail on the stochastic model formulation. ** - -```{r, echo = FALSE, message = FALSE} -DiagrammeR::grViz("digraph { - - # graph statement - ################# - graph [layout = dot, - rankdir = LR, - overlap = true, - fontsize = 10] - - # nodes - ####### - node [shape = square, - fixedsize = true - width = 1.3] - - S - E - I - H - F - R - - # edges - ####### - S -> E [label = ' infection (β)'] - E -> I [label = ' onset of \ninfectiousness (γ E)'] - I -> F [label = ' death (funeral) \n(γ I)'] - F -> R [label = ' safe burial (one timestep) '] - I -> H [label = ' hospitalisation (p hosp)'] - H -> R [label = ' recovery or safe burial \n (γ I)'] - - subgraph { - rank = same; I; F; - } - subgraph { - rank = same; H; R; - } -}") -``` - -The model has additional parameters describing the transmission risk in hospital and funeral settings: - -+ $p_{ETU}$, the proportion of hospitalised cases contributing to the infection of susceptibles (ETU = Ebola virus treatment units), -+ $p_{funeral}$, the proportion of funerals at which the risk of transmission is the same as of infectious individuals in the community. - -As this model is stochastic, it is the most appropriate choice to explore how variation in numbers of infected individuals in the early stages of an Ebola outbreak. - - -::::::::::::::::::::::::::: - - -:::::::::::::::::::::::::::::::::::::::::::::::: - - -## Challenge : Ebola outbreak analysis - - - -::::::::::::::::::::::::::::::::::::: challenge - -## Running the model - -You have been tasked to generate initial trajectories of an Ebola outbreak in Guinea. Using `model_ebola_r()` and the the information detailed below, complete the following tasks: - -1. Run the model once and plot the number of infectious individuals through time -2. Run model 100 times and plot the mean, upper and lower 95% quantiles of the number of infectious individuals through time - -+ Population size : 14 million -+ Initial number of exposed individuals : 10 -+ Initial number of infectious individuals : 5 -+ Time of simulation : 120 days -+ Parameter values : - + $R_0$ (`r0`) = 1.1, - + $p^I$ (`infectious_period`) = 12, - + $p^E$ (`preinfectious_period`) = 5, - + $k^E=k^I = 2$, - + $1-p_{hosp}$ (`prop_community`) = 0.9, - + $p_{ETU}$ (`etu_risk`) = 0.7, - + $p_{funeral}$ (`funeral_risk`) = 0.5 - -::::::::::::::::: hint - -### Code for initial conditions - -```{r} -# set population size -population_size <- 14e6 - -E0 <- 10 -I0 <- 5 -# prepare initial conditions as proportions -initial_conditions <- c( - S = population_size - (E0 + I0), E = E0, I = I0, H = 0, F = 0, R = 0 -) / population_size - -guinea_population <- population( - name = "Guinea", - contact_matrix = matrix(1), # note dummy value - demography_vector = population_size, # 14 million, no age groups - initial_conditions = matrix( - initial_conditions, - nrow = 1 - ) -) -``` - - -:::::::::::::::::::::: - - -::::::::::::::::: hint - -### HINT : Multiple model simulations - -Adapt the code from the [accounting for uncertainty](../episodes/simulating-transmission.md#accounting-for-uncertainty) section - -:::::::::::::::::::::: - -::::::::::::::::: solution - -### SOLUTION - -1. Run the model once and plot the number of infectious individuals through time - - -```{r} -output <- model_ebola_r( - population = guinea_population, - transmissibility = 1.1 / 12, - infectiousness_rate = 2.0 / 5, - removal_rate = 2.0 / 12, - prop_community = 0.9, - etu_risk = 0.7, - funeral_risk = 0.5, - time_end = 100 -) - -ggplot(output[output$compartment == "infectious", ]) + - geom_line( - aes(time, value), - linewidth = 1.2 - ) + - scale_y_continuous( - labels = scales::comma - ) + - labs( - x = "Simulation time (days)", - y = "Individuals" - ) + - theme_bw( - base_size = 15 - ) -``` - -2. Run model 100 times and plot the mean, upper and lower 95% quantiles of the number of infectious individuals through time - -We run the model 100 times with the *same* parameter values. - -```{r} -output_samples <- Map( - x = seq(100), - f = function(x) { - output <- model_ebola_r( - population = guinea_population, - transmissibility = 1.1 / 12, - infectiousness_rate = 2.0 / 5, - removal_rate = 2.0 / 12, - prop_community = 0.9, - etu_risk = 0.7, - funeral_risk = 0.5, - time_end = 100 - ) - # add replicate number and return data - output$replicate <- x - output - } -) - -output_samples <- bind_rows(output_samples) # requires the dplyr package - -ggplot( - output_samples[output_samples$compartment == "infectious", ], - aes(time, value) -) + - stat_summary(geom = "line", fun = mean) + - stat_summary( - geom = "ribbon", - fun.min = function(z) { - quantile(z, 0.025) - }, - fun.max = function(z) { - quantile(z, 0.975) - }, - alpha = 0.3 - ) + - labs( - x = "Simulation time (days)", - y = "Individuals" - ) + - theme_bw( - base_size = 15 - ) -``` - -::::::::::::::::::::::::::: - - -:::::::::::::::::::::::::::::::::::::::::::::::: - - - -::::::::::::::::::::::::::::::::::::: keypoints - -- Existing mathematical models should be selected according to the research question -- It is important to check that a model has appropriate assumptions about transmission, outbreak potential, outcomes and interventions -:::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/episodes/modelling-interventions.Rmd b/episodes/modelling-interventions.Rmd deleted file mode 100644 index fd035843..00000000 --- a/episodes/modelling-interventions.Rmd +++ /dev/null @@ -1,442 +0,0 @@ ---- -title: 'Modelling interventions' -teaching: 45 # teaching time in minutes -exercises: 30 # exercise time in minutes - ---- - -```{r setup, echo= FALSE, message = FALSE, warning = FALSE} -library(ggplot2) -library(epidemics) -``` - -:::::::::::::::::::::::::::::::::::::: questions - -- How do I investigate the effect of interventions on disease trajectories? - - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: objectives - -- Add pharmaceutical and non-pharmaceutical interventions to an {epidemics} model - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: prereq - -## Prerequisites -+ Complete tutorial [Simulating transmission](../episodes/simulating-transmission.md) - -Learners should familiarise themselves with following concept dependencies before working through this tutorial: - -**Outbreak response** : [Intervention types](https://www.cdc.gov/nonpharmaceutical-interventions/). -::::::::::::::::::::::::::::::::: - - -## Introduction - -Mathematical models can be used to generate trajectories of disease spread under the implementation of interventions at different stages of an outbreak. These predictions can be used to make decisions on what interventions could be implemented to slow down the spread of diseases. - -We can assume interventions in mathematical models reduce the values of relevant parameters e.g. reduce transmissibility while in place. Or it may be appropriate to assume individuals are classified into a new disease state, e.g. once vaccinated we assume individuals are no longer susceptible to infection and therefore move to a vaccinated state. In this tutorial, we will introduce how to include three different interventions in model of COVID-19 transmission. - -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: instructor - -In this tutorial different types of intervention and how they can be modelled are introduced. Learners should be able to understand the underlying mechanism of these interventions (e.g. reduce contact rate) as well as how to implement the code to include such interventions. - -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -## Non-pharmaceutical interventions - -[Non-pharmaceutical interventions](../learners/reference.md#NPIs) (NPIs) are measures put in place to reduce transmission that do not include the administration of drugs or vaccinations. NPIs aim reduce contact between infectious and susceptible individuals. For example, washing hands, wearing masks and closures of school and workplaces. - -We will investigate the effect of interventions on a COVID-19 outbreak using an SEIR model (`model_default_cpp()` in the R package `{epidemics}`). We will set $R_0 = 2.7$, latent period or 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. - -```{r model_setup, echo = TRUE, message = FALSE} -polymod <- socialmixr::polymod -contact_data <- socialmixr::contact_matrix( - polymod, - countries = "United Kingdom", - age.limits = c(0, 15, 65), - symmetric = TRUE -) - -# prepare contact matrix -contact_matrix <- t(contact_data$matrix) - -# prepare the demography vector -demography_vector <- contact_data$demography$population -names(demography_vector) <- rownames(contact_matrix) - -# initial conditions: one in every 1 million is infected -initial_i <- 1e-6 -initial_conditions <- c( - S = 1 - initial_i, E = 0, I = initial_i, R = 0, V = 0 -) - -# build for all age groups -initial_conditions <- matrix( - rep(initial_conditions, dim(contact_matrix)[1]), - ncol = 5, byrow = TRUE -) -rownames(initial_conditions) <- rownames(contact_matrix) - -# prepare the population to model as affected by the epidemic -uk_population <- population( - name = "UK", - contact_matrix = contact_matrix, - demography_vector = demography_vector, - initial_conditions = initial_conditions -) -``` - -#### Effect of school closures on COVID-19 spread - -The first NPI we will consider is 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. We 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). - -To include an intervention in our model we must create an `intervention` object. The inputs are the name of the intervention (`name`), the type of intervention (`contacts` or `rate`), the start time (`time_begin`), the end time (`time_end`) and the reduction (`reduction`). The values of the reduction matrix are specified in the same order as the age groups in the contact matrix. - -```{r} -rownames(contact_matrix) -``` - -Therefore, we specify ` reduction = matrix(c(0.5, 0.01, 0.01))`. We assume that the school closures start on day 50 and are in place for a further 100 days. Therefore our intervention object is : - -```{r intervention} -close_schools <- intervention( - name = "School closure", - type = "contacts", - time_begin = 50, - time_end = 50 + 100, - reduction = matrix(c(0.5, 0.01, 0.01)) -) -``` - -::::::::::::::::::::::::::::::::::::: callout -### Effect of interventions on contacts - -In `epidemics`, the contact matrix is scaled down by proportions for the period in which the intervention is in place. To understand how the reduction is calculated within the model functions, consider a contact matrix for two age groups with equal number of contacts: - -```{r echo = FALSE} -reduction <- matrix(c(0.5, 0.1)) -contact_matrix_example <- matrix(c(1, 1, 1, 1), nrow = 2) -contact_matrix_example -``` - -If the reduction is 50% in group 1 and 10% in group 2, the contact matrix during the intervention will be: - -```{r echo = FALSE} -contact_matrix_example[1, ] <- contact_matrix_example[1, ] * (1 - reduction[1]) -contact_matrix_example[, 1] <- contact_matrix_example[, 1] * (1 - reduction[1]) -contact_matrix_example[2, ] <- contact_matrix_example[2, ] * (1 - reduction[2]) -contact_matrix_example[, 2] <- contact_matrix_example[, 2] * (1 - reduction[2]) -contact_matrix_example -``` - -The contacts within group 1 are reduced by 50% twice to accommodate for a 50% reduction in outgoing and incoming contacts ($1\times 0.5 \times 0.5 = 0.25$). Similarly, the contacts within group 2 are reduced by 10% twice. The contacts between group 1 and group 2 are reduced by 50% and then by 10% ($1 \times 0.5 \times 0.9= 0.45$). - -:::::::::::::::::::::::::::::::::::::::::::::::: - -Using transmissibility $= 2.7/5.5$ (remember that [transmissibility = $R_0$/ infectious period](../episodes/simulating-transmission.md#the-basic-reproduction-number-r_0)), infectiousness rate $1/= 4$ and the recovery rate $= 1/5.5$ we run the model with` intervention = list(contacts = close_schools)` as follows : - -```{r school} -output_school <- model_default_cpp( - population = uk_population, - transmissibility = 2.7 / 5.5, - infectiousness_rate = 1.0 / 4.0, - recovery_rate = 1.0 / 5.5, - intervention = list(contacts = close_schools), - time_end = 300, increment = 1.0 -) -``` - - -To be able to see the effect of our intervention, we also run the model where there is no intervention, combine the two outputs into one data frame and then plot the output. Here we plot the total number of infectious individuals in all age groups using `ggplot2::stat_summary()`: - -```{r baseline, echo = TRUE, fig.width = 10} -# run baseline simulation with no intervention -output_baseline <- model_default_cpp( - population = uk_population, - transmissibility = 2.7 / 5.5, - infectiousness_rate = 1.0 / 4.0, - recovery_rate = 1.0 / 5.5, - time_end = 300, increment = 1.0 -) - -# create intervention_type column for plotting -output_school$intervention_type <- "school closure" -output_baseline$intervention_type <- "baseline" -output <- rbind(output_school, output_baseline) - -ggplot(data = output[output$compartment == "infectious", ]) + - aes( - x = time, - y = value, - color = intervention_type, - linetype = intervention_type - ) + - stat_summary( - fun = "sum", - geom = "line", - linewidth = 1 - ) + - scale_y_continuous( - labels = scales::comma - ) + - labs( - x = "Simulation time (days)", - y = "Individuals" - ) + - theme_bw( - base_size = 15 - ) + - geom_vline( - xintercept = c(close_schools$time_begin, close_schools$time_end), - colour = "black", - linetype = "dashed", - linewidth = 0.2 - ) + - annotate( - geom = "text", - label = "Schools closed", - colour = "black", - x = (close_schools$time_end - close_schools$time_begin) / 2 + - close_schools$time_begin, - y = 10, - angle = 0, - vjust = "outward" - ) -``` -We see that with the intervention in place, the infection still spreads through the population, though the peak number of infectious individuals is smaller than the baseline with no intervention in place (solid line). - - - -#### Effect of mask wearing on COVID-19 spread - -We can model the effect of other NPIs as reducing the value of relevant parameters. For example, we want to investigate the effect of mask wearing on the number of individuals infectious with COVID-19 through time. - -We expect that mask wearing will reduce an individual's infectiousness. As we are using a population based model, we cannot make changes to individual behaviour and so assume that the transmissibility $\beta$ is reduced by a proportion due to mask wearing in the population. We specify this proportion, $\theta$ as product of the proportion wearing masks multiplied by the proportion reduction in transmissibility (adapted from [Li et al. 2020](https://doi.org/10.1371/journal.pone.0237691)) - -We create an intervention object with `type = rate` and `reduction = 0.161`. Using parameters adapted from [Li et al. 2020](https://doi.org/10.1371/journal.pone.0237691) we have proportion wearing masks = coverage $\times$ availability = $0.54 \times 0.525 = 0.2835$, proportion reduction in transmissibility = $0.575$. Therefore, $\theta = 0.2835 \times 0.575 = 0.163$. We assume that the mask wearing mandate starts at day 40 and is in place for 200 days. - -```{r masks} -mask_mandate <- intervention( - name = "mask mandate", - type = "rate", - time_begin = 40, - time_end = 40 + 200, - reduction = 0.163 -) -``` - -To implement this intervention on the parameter $\beta$, we specify `intervention = list(beta = mask_mandate)`. - -```{r output_masks} -output_masks <- model_default_cpp( - population = uk_population, - transmissibility = 2.7 / 5.5, - infectiousness_rate = 1.0 / 4.0, - recovery_rate = 1.0 / 5.5, - intervention = list(transmissibility = mask_mandate), - time_end = 300, increment = 1.0 -) -``` - - -```{r plot_masks, echo = TRUE, message = FALSE, fig.width = 10} -# create intervention_type column for plotting -output_masks$intervention_type <- "mask mandate" -output_baseline$intervention_type <- "baseline" -output <- rbind(output_masks, output_baseline) - -ggplot(data = output[output$compartment == "infectious", ]) + - aes( - x = time, - y = value, - color = intervention_type, - linetype = intervention_type - ) + - stat_summary( - fun = "sum", - geom = "line", - linewidth = 1 - ) + - scale_y_continuous( - labels = scales::comma - ) + - labs( - x = "Simulation time (days)", - y = "Individuals" - ) + - theme_bw( - base_size = 15 - ) + - geom_vline( - xintercept = c(mask_mandate$time_begin, mask_mandate$time_end), - colour = "black", - linetype = "dashed", - linewidth = 0.2 - ) + - annotate( - geom = "text", - label = "Mask mandate", - colour = "black", - x = (mask_mandate$time_end - mask_mandate$time_begin) / 2 + - mask_mandate$time_begin, - y = 10, - angle = 0, - vjust = "outward" - ) -``` - -::::::::::::::::::::::::::::::::::::: callout -### Intervention types - -There are two intervention types for `model_default_cpp()`. Rate interventions on model parameters (`transmissibillity` $\beta$, `infectiousness_rate` $\sigma$ and `recovery_rate` $\gamma$) and contact matrix reductions `contacts`. - -To implement both contact and rate interventions in the same simulation they must be passed as a list e.g. `intervention = list(transmissibility = mask_mandate, contacts = close_schools)`. But if there are multiple interventions that target contact rates, these must be passed as one `contacts` input. See the [vignette on modelling overlapping interventions](https://epiverse-trace.github.io/epidemics/articles/multiple_interventions.html) for more detail. - -:::::::::::::::::::::::::::::::::::::::::::::::: - - -## Pharmaceutical interventions - -Pharmaceutical interventions (PIs) are measures such as vaccination and mass treatment programs. In the previous section, we assumed that interventions reduced the value of parameter values while the intervention was in place. In the case of vaccination, we assume that after the intervention individuals are no longer susceptible and should be classified into a different disease state. Therefore, we specify the rate at which individuals are vaccinated and track the number of vaccinated individuals through time. - -The diagram below shows the SEIRV model implemented using `model_default_cpp()` where susceptible individuals are vaccinated and then move to the $V$ class. - -```{r diagram_SEIRV, echo = FALSE, message = FALSE} -DiagrammeR::grViz("digraph { - - # graph statement - ################# - graph [layout = dot, - rankdir = LR, - overlap = true, - fontsize = 10] - - # nodes - ####### - node [shape = square, - fixedsize = true - width = 1.3] - - S - E - I - R - V - - # edges - ####### - S -> E [label = ' infection (β)'] - S -> V [label = ' vaccination (ν)'] - E -> I [label = ' onset of \ninfectiousness (α)'] - I -> R [label = ' recovery (γ)'] - -}") -``` - - - -The equations describing this model are as follows: - -$$ -\begin{aligned} -\frac{dS_i}{dt} & = - \beta S_i \sum_j C_{i,j} I_j -\nu_{t} S_i \\ -\frac{dE_i}{dt} &= \beta S_i\sum_j C_{i,j} I_j - \alpha E_i \\ -\frac{dI_i}{dt} &= \alpha E_i - \gamma I_i \\ -\frac{dR_i}{dt} &=\gamma I_i \\ -\frac{dV_i}{dt} & =\nu_{i,t} S_i\\ -\end{aligned} -$$ -Individuals are vaccinated at an age group ($i$) specific time dependent ($t$) vaccination rate ($\nu_{i,t}$). The SEIR components of these equations are described in the tutorial [simulating transmission](../episodes/simulating-transmission.md#simulating-disease-spread). - -To explore the effect of vaccination we need to create a vaccination object to pass as an input into `model_default_cpp()` that includes an age groups specific vaccination rate `nu` and age group specific start and end times of the vaccination program (`time_begin` and `time_end`). - -Here we will assume all age groups are vaccinated at the same rate 0.01 and that the vaccination program starts on day 40 and is in place for 150 days. - -```{r vaccinate} -# prepare a vaccination object -vaccinate <- vaccination( - name = "vaccinate all", - time_begin = matrix(40, nrow(contact_matrix)), - time_end = matrix(40 + 150, nrow(contact_matrix)), - nu = matrix(c(0.01, 0.01, 0.01)) -) -``` - -We pass our vaccination object using `vaccination = vaccinate`: - -```{r output_vaccinate} -output_vaccinate <- model_default_cpp( - population = uk_population, - transmissibility = 2.7 / 5.5, - infectiousness_rate = 1.0 / 4.0, - recovery_rate = 1.0 / 5.5, - vaccination = vaccinate, - time_end = 300, increment = 1.0 -) -``` - - -::::::::::::::::::::::::::::::::::::: challenge - -## Compare interventions - -Plot the three interventions vaccination, school closure and mask mandate and the baseline simulation on one plot. Which intervention reduces the peak number of infectious individuals the most? - - -:::::::::::::::::::::::: solution - -## Output - -```{r plot_vaccinate, echo = TRUE, message = FALSE, fig.width = 10} -# create intervention_type column for plotting -output_vaccinate$intervention_type <- "vaccination" -output <- rbind(output_school, output_masks, output_vaccinate, output_baseline) - -ggplot(data = output[output$compartment == "infectious", ]) + - aes( - x = time, - y = value, - color = intervention_type, - linetype = intervention_type - ) + - stat_summary( - fun = "sum", - geom = "line", - linewidth = 1 - ) + - scale_y_continuous( - labels = scales::comma - ) + - labs( - x = "Simulation time (days)", - y = "Individuals" - ) + - theme_bw( - base_size = 15 - ) -``` - -From the plot we see that the peak number of total number of infectious individuals when vaccination is in place is much lower compared to school closures and mask wearing interventions. - -::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::: - - - - -## Summary - -Different types of intervention can be implemented using mathematical modelling. Modelling interventions requires assumptions of which model parameters are affected (e.g. contact matrices, transmissibility), by what magnitude and and what times in the simulation of an outbreak. - -The next step is to quantify the effect of an interventions. If you are interested in learning how to compare interventions, please complete the tutorial [Comparing public health outcomes of interventions](../episodes/compare-interventions.md). - -::::::::::::::::::::::::::::::::::::: keypoints - -- The effect of NPIs can be modelled as reducing contact rates between age groups or reducing the transmissibility of infection -- Vaccination can be modelled by assuming individuals move to a different disease state $V$ - -:::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/episodes/quantify-transmissibility.Rmd b/episodes/quantify-transmissibility.Rmd deleted file mode 100644 index 1ecf1b9a..00000000 --- a/episodes/quantify-transmissibility.Rmd +++ /dev/null @@ -1,416 +0,0 @@ ---- -title: 'Quantifying transmission' -teaching: 30 -exercises: 0 ---- - -```{r setup, echo = FALSE, warning = FALSE, message = FALSE} -library(EpiNow2) -library(ggplot2) -withr::local_options(list(mc.cores = 4)) -``` - -:::::::::::::::::::::::::::::::::::::: questions - -- How can I estimate key transmission metrics from a time series of case data? -- How can I quantify geographical heterogeneity in these metrics? - - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: objectives - -- Learn how to estimate transmission metrics from a time series of case data using the R package `EpiNow2` - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: prereq - -## Prerequisites - -Learners should familiarise themselves with following concept dependencies before working through this tutorial: - -**Statistics** : probability distributions, principle of Bayesian analysis. - -**Epidemic theory** : Effective reproduction number. - -::::::::::::::::::::::::::::::::: - - - -::::::::::::::::::::::::::::::::::::: callout -### Reminder: the Effective Reproduction Number, $R_t$ - -The [basic reproduction number](../learners/reference.md#basic), $R_0$, is the average number of cases caused by one infectious individual in a entirely susceptible population. - -But in an ongoing outbreak, the population does not remain entirely susceptible as those that recover from infection are typically immune. Moreover, there can be changes in behaviour or other factors that affect transmission. When we are interested in monitoring changes in transmission we are therefore more interested in the value of the **effective reproduction number**, $R_t$, the average number of cases caused by one infectious individual in the population at time $t$. - -:::::::::::::::::::::::::::::::::::::::::::::::: - - -## Introduction - -Quantifying transmission metrics at the start of an outbreak can give important information on the strength of transmission (reproduction number) and the speed of transmission ([growth rate](../learners/reference.md#growth), doubling/halving time). To estimate these key metrics using case data we must account for delays between the date of infections and date of reported cases. In an outbreak situation, data are usually available on reported dates only, therefore we must use estimation methods to account for these delays when trying to understand changes in transmission over time. - -In the next tutorials we will focus on how to implement the functions in `{EpiNow2}` to estimate transmission metrics of case data. We will not cover the theoretical background of the models or inference framework, for details on these concepts see the [vignette](https://epiforecasts.io/EpiNow2/dev/articles/estimate_infections.html). -For more details on the distinction between speed and strength of transmission and implications for control, see [Dushoff & Park, 2021](https://royalsocietypublishing.org/doi/full/10.1098/rspb.2020.1556). - - -::::::::::::::::::::::::::::::::::::: callout -### Bayesian inference - -The R package `EpiNow2` uses a [Bayesian inference](../learners/reference.md#bayesian) framework to estimate reproduction numbers and infection times based on reporting dates. - -In Bayesian inference, we use prior knowledge (prior distributions) with data (in a likelihood function) to find the posterior probability. - -

Posterior probability $\propto$ likelihood $\times$ prior probability -

- -:::::::::::::::::::::::::::::::::::::::::::::::: - - -The first step is to load the `{EpiNow2}` package : - -```{r, eval = FALSE} -library(EpiNow2) -``` - -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: instructor - -This tutorial illustrates the usage of `epinow()` to estimate the time-varying reproduction number and infection times. Learners should understand the necessary inputs to the model and the limitations of the model output. - -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - - -## Delay distributions and case data -### Case data - -To illustrate the functions of `EpiNow2` we will use outbreak data of the start of the COVID-19 pandemic from the United Kingdom. The data are available in the R package `{incidence2}`. - -```{r} -head(incidence2::covidregionaldataUK) -``` - -To use the data, we must format the data to have two columns: - -+ `date` : the date (as a date object see `?is.Date()`), -+ `confirm` : number of confirmed cases on that date. - -```{r} -cases <- aggregate( - cases_new ~ date, - data = incidence2::covidregionaldataUK[, c("date", "cases_new")], - FUN = sum -) -colnames(cases) <- c("date", "confirm") -``` - - -There are case data available for `r dim(cases)[1]` days, but in an outbreak situation it is likely we would only have access to the beginning of this data set. Therefore we assume we only have the first 90 days of this data. - -```{r echo = FALSE} -ggplot(cases[1:90, ], aes(x = date, y = confirm)) + - geom_col() + - theme_grey( - base_size = 15 - ) -``` - - - -### Delay distributions -We assume there are delays from the time of infection until the time a case is reported. We specify these delays as distributions to account for the uncertainty in individual level differences. The delay can consist of multiple types of delays/processes. A typical delay from time of infection to case reporting may consist of : - -

**time from infection to symptom onset** (the [incubation period](../learners/reference.md#incubation)) + **time from symptom onset to case notification** (the reporting time) -.

- -The delay distribution for each of these processes can either estimated from data or obtained from the literature. We can express uncertainty about what the correct parameters of the distributions by assuming the distributions have **fixed** parameters or whether they have **variable** parameters. To understand the difference between **fixed** and **variable** distributions, let's consider the incubation period. - -::::::::::::::::::::::::::::::::::::: callout -### Delays and data -The number of delays and type of delay is a flexible input that depends on the data. The examples below highlight how the delays can be specified for different data sources: - -
- -| Data source | Delay(s) | -| ------------- |-------------| -|Time of case report |Incubation period + time from symptom onset to case notification | -|Time of hospitalisation |Incubation period + time from symptom onset to hospitalisation | -|Time of symptom onset |Incubation period | - -
- - -:::::::::::::::::::::::::::::::::::::::::::::::: - - - -#### Incubation period distribution - -The distribution of incubation period can usually be obtained from the literature. The package `{epiparameter}` contains a library of epidemiological parameters for different diseases obtained from the literature. - -We specify a (fixed) gamma distribution with mean $\mu = 4$ and standard deviation $\sigma^2= 2$ (shape = $4$, scale = $1$) using the function `dist_spec()` as follows: - -```{r} -incubation_period_fixed <- dist_spec( - mean = 4, sd = 2, - max = 20, distribution = "gamma" -) -incubation_period_fixed -``` - -The argument `max` is the maximum value the distribution can take, in this example 20 days. - -::::::::::::::::::::::::::::::::::::: callout -### Why a gamma distrubution? - -The incubation period has to be positive in value. Therefore we must specific a distribution in `dist_spec` which is for positive values only. - -`dist_spec()` supports log normal and gamma distributions, which are distributions for positive values only. - -For all types of delay, we will need to use distributions for positive values only - we don't want to include delays of negative days in our analysis! - -:::::::::::::::::::::::::::::::::::::::::::::::: - - - -#### Including distribution uncertainty - -To specify a **variable** distribution, we include uncertainty around the mean $\mu$ and standard deviation $\sigma^2$ of our gamma distribution. If our incubation period distribution has a mean $\mu$ and standard deviation $\sigma^2$, then we assume the mean ($\mu$) follows a Normal distribution with standard deviation $\sigma_{\mu}^2$: - -$$\mbox{Normal}(\mu,\sigma_{\mu}^2)$$ - -and a standard deviation ($\sigma^2$) follows a Normal distribution with standard deviation $\sigma_{\sigma^2}^2$: - -$$\mbox{Normal}(\sigma^2,\sigma_{\sigma^2}^2).$$ - -We specify this using `dist_spec` with the additional arguments `mean_sd` ($\sigma_{\mu}^2$) and `sd_sd` ($\sigma_{\sigma^2}^2$). - -```{r} -incubation_period_variable <- dist_spec( - mean = 4, sd = 2, - mean_sd = 0.5, sd_sd = 0.5, - max = 20, distribution = "gamma" -) -incubation_period_variable -``` - - - -#### Reporting delays - -After the incubation period, there will be an additional delay of time from symptom onset to case notification: the reporting delay. We can specify this as a fixed or variable distribution, or estimate a distribution from data. - -When specifying a distribution, it is useful to visualise the probability density to see the peak and spread of the distribution, in this case we will use a log normal distribution. We can use the functions `convert_to_logmean()` and `convert_to_logsd()` to convert the mean and standard deviation of a normal distribution to that of a log normal distribution. - -If we want to assume that the mean reporting delay is 2 days (with a standard deviation of 1 day), the log normal distribution will look like: - -```{r} -log_mean <- convert_to_logmean(2, 1) -log_sd <- convert_to_logsd(2, 1) -x <- seq(from = 0, to = 10, length = 1000) -df <- data.frame(x = x, density = dlnorm(x, meanlog = log_mean, sdlog = log_sd)) -ggplot(df) + - geom_line( - aes(x, density) - ) + - theme_grey( - base_size = 15 - ) -``` - -Using the mean and standard deviation for the log normal distribution, we can specify a fixed or variable distribution using `dist_spec()` as before: - -```{r} -reporting_delay_variable <- dist_spec( - mean = log_mean, sd = log_sd, - mean_sd = 0.5, sd_sd = 0.5, - max = 10, distribution = "lognormal" -) -``` - -If data is available on the time between symptom onset and reporting, we can use the function `estimate_delay()` to estimate a log normal distribution from a vector of delays. The code below illustrates how to use `estimate_delay()` with synthetic delay data. - -```{r, eval = FALSE } -delay_data <- rlnorm(500, log(5), 1) # synthetic delay data -reporting_delay <- estimate_delay( - delay_data, - samples = 1000, - bootstraps = 10 -) -``` - - -#### Generation time - -We also must specify a distribution for the generation time. Here we will use a log normal distribution with mean 3.6 and standard deviation 3.1 ([Ganyani et al. 2020](https://doi.org/10.2807/1560-7917.ES.2020.25.17.2000257)). - - -```{r} -generation_time_variable <- dist_spec( - mean = 3.6, sd = 3.1, - mean_sd = 0.5, sd_sd = 0.5, - max = 20, distribution = "lognormal" -) -``` - - -## Finding estimates - -The function `epinow()` is a wrapper for the function `estimate_infections()` used to estimate cases by date of infection. The generation time distribution and delay distributions must be passed using the functions ` generation_time_opts()` and `delay_opts()` respectively. - -There are numerous other inputs that can be passed to `epinow()`, see `EpiNow2::?epinow()` for more detail. -One optional input is to specify a log normal prior for the effective reproduction number $R_t$ at the start of the outbreak. We specify a mean and standard deviation as arguments of `prior` within `rt_opts()`: - -```{r, eval = FALSE} -rt_log_mean <- convert_to_logmean(2, 1) -rt_log_sd <- convert_to_logsd(2, 1) -rt <- rt_opts(prior = list(mean = rt_log_mean, sd = rt_log_sd)) -``` - -::::::::::::::::::::::::::::::::::::: callout -### Bayesian inference using Stan - -The Bayesian inference is performed using MCMC methods with the program [Stan](https://mc-stan.org/). There are a number of default inputs to the Stan functions including the number of chains and number of samples per chain (see `?EpiNow2::stan_opts()`). - -To reduce computation time, we can run chains in parallel. To do this, we must set the number of cores to be used. By default, 4 MCMC chains are run (see `stan_opts()$chains`), so we can set an equal number of cores to be used in parallel as follows: - -```{r} -withr::local_options(list(mc.cores = 4)) -``` - -To find the maximum number of available cores on your machine, use `parallel::detectCores()`. - -:::::::::::::::::::::::::::::::::::::::::::::::: - -```{r, echo = FALSE} -rt_log_mean <- convert_to_logmean(2, 1) -rt_log_sd <- convert_to_logsd(2, 1) - -incubation_period_fixed <- dist_spec( - mean = 4, sd = 2, - max = 20, distribution = "gamma" -) - -log_mean <- convert_to_logmean(2, 1) -log_sd <- convert_to_logsd(2, 1) -reporting_delay_fixed <- dist_spec( - mean = log_mean, sd = log_sd, - max = 10, distribution = "lognormal" -) - -generation_time_fixed <- dist_spec( - mean = 3.6, sd = 3.1, - max = 20, distribution = "lognormal" -) -``` - -*Note : in the code below fixed distributions are used instead of variable. This is to speed up computation time. It is generally recommended to use variable distributions that account for additional uncertainty.* - -```{r, message = FALSE, eval = TRUE} -reported_cases <- cases[1:90, ] -estimates <- epinow( - reported_cases = reported_cases, - generation_time = generation_time_opts(generation_time_fixed), - delays = delay_opts(incubation_period_fixed + reporting_delay_fixed), - rt = rt_opts(prior = list(mean = rt_log_mean, sd = rt_log_sd)) -) -``` - -### Results - -We can extract and visualise estimates of the effective reproduction number through time: - -```{r} -estimates$plots$R -``` - -The uncertainty in the estimates increases through time. This is because estimates are informed by data in the past - within the delay periods. This difference in uncertainty is categorised into **Estimate** (green) utilises all data and **Estimate based on partial data** (orange) estimates that are based on less data (because infections that happened at the time are more likely to not have been observed yet) and therefore have increasingly wider intervals towards the date of the last data point. Finally, the **Forecast** (purple) is a projection ahead of time. - -We can also visualise the growth rate estimate through time: -```{r} -estimates$plots$growth_rate -``` - -To extract a summary of the key transmission metrics at the *latest date* in the data: - -```{r} -summary(estimates) -``` - -As these estimates are based on partial data, they have a wide uncertainty interval. - -+ From the summary of our analysis we see that the expected change in daily cases is `r summary(estimates)$estimate[summary(estimates)$measure=="Expected change in daily cases"]` with the estimated new confirmed cases `r summary(estimates)$estimate[summary(estimates)$measure=="New confirmed cases by infection date"]`. - -+ The effective reproduction number $R_t$ estimate (on the last date of the data) is `r summary(estimates)$estimate[summary(estimates)$measure=="Effective reproduction no."]`. - -+ The exponential growth rate of case numbers is `r summary(estimates)$estimate[summary(estimates)$measure=="Rate of growth"]`. - -+ The doubling time (the time taken for case numbers to double) is `r summary(estimates)$estimate[summary(estimates)$measure=="Doubling/halving time (days)"]`. - -::::::::::::::::::::::::::::::::::::: callout -### `Expected change in daily cases` - -A factor describing expected change in daily cases based on the posterior probability that $R_t < 1$. - -
-| Probability ($p$) | Expected change | -| ------------- |-------------| -|$p < 0.05$ |Increasing | -|$0.05 \leq p< 0.4$ |Likely increasing | -|$0.4 \leq p< 0.6$ |Stable | -|$0.6 \leq p < 0.95$ |Likely decreasing | -|$0.95 \leq p \leq 1$ |Decreasing | -
- -:::::::::::::::::::::::::::::::::::::::::::::::: - - - - -## Quantify geographical heterogeneity - -The outbreak data of the start of the COVID-19 pandemic from the United Kingdom from the R package `{incidence2}` includes the region in which the cases were recorded. To find regional estimates of the effective reproduction number and cases, we must format the data to have three columns: - -+ `date` : the date, -+ `region` : the region, -+ `confirm` : number of confirmed cases for a region on a given date. - -```{r} -regional_cases <- - incidence2::covidregionaldataUK[, c("date", "cases_new", "region")] -colnames(regional_cases) <- c("date", "confirm", "region") - -# extract the first 90 dates for all regions -dates <- sort(unique(regional_cases$date))[1:90] -regional_cases <- regional_cases[which(regional_cases$date %in% dates), ] - -head(regional_cases) -``` - -To find regional estimates, we use the same inputs as `epinow()` to the function `regional_epinow()`: - -```{r, message = FALSE, eval = TRUE} -estimates_regional <- regional_epinow( - reported_cases = regional_cases, - generation_time = generation_time_opts(generation_time_fixed), - delays = delay_opts(incubation_period_fixed + reporting_delay_fixed), - rt = rt_opts(prior = list(mean = rt_log_mean, sd = rt_log_sd)) -) - -estimates_regional$summary$summarised_results$table - -estimates_regional$summary$plots$R -``` - - -## Summary - -`EpiNow2` can be used to estimate transmission metrics from case data at the start of an outbreak. The reliability of these estimates depends on the quality of the data and appropriate choice of delay distributions. In the next tutorial we will learn how to make forecasts and investigate some of the additional inference options available in `EpiNow2`. - -::::::::::::::::::::::::::::::::::::: keypoints - -- Transmission metrics can be estimated from case data after accounting for delays -- Uncertainty can be accounted for in delay distributions - -:::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/episodes/simulating-transmission.Rmd b/episodes/simulating-transmission.Rmd deleted file mode 100644 index c0804502..00000000 --- a/episodes/simulating-transmission.Rmd +++ /dev/null @@ -1,555 +0,0 @@ ---- -title: 'Simulating transmission' -teaching: 45 # teaching time in minutes -exercises: 30 # exercise time in minutes ---- - -```{r setup, echo= FALSE, message = FALSE, warning = FALSE} -library(ggplot2) -library(dplyr) -library(tidyverse) -library(DiagrammeR) -library(webshot) -library(epidemics) -webshot::install_phantomjs(force = TRUE) -``` - - -:::::::::::::::::::::::::::::::::::::: questions - -- How do I simulate disease spread using a mathematical model? -- What inputs are needed for a model simulation? -- How do I account for uncertainty? - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: objectives - -- Load an existing model structure from `{epidemics}` R package -- Load an existing social contact matrix with `{socialmixr}` -- Generate a disease spread model simulation with `{epidemics}` -- Generate multiple model simulations and visualise uncertainty - -:::::::::::::::::::::::::::::::::::::::::::::::: - -::::::::::::::::::::::::::::::::::::: prereq - -## Prerequisites - -Learners should familiarise themselves with following concept dependencies before working through this tutorial: - -**Mathematical Modelling** : [Introduction to infectious disease models](https://doi.org/10.1038/s41592-020-0856-2), [state variables](../learners/reference.md#state), [model parameters](../learners/reference.md#parsode), [initial conditions](../learners/reference.md#initial), [ordinary differential equations](../learners/reference.md#ordinary). - -**Epidemic theory** : [Transmission](https://doi.org/10.1155/2011/267049), [Reproduction number](https://doi.org/10.3201/eid2501.171901). -::::::::::::::::::::::::::::::::: - - - -## Introduction - -Mathematical models are useful tools for generating future trajectories of disease spread. In this tutorial, we will use the R package `{epidemics}` to generate disease trajectories of an influenza strain with pandemic potential. 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 over time. - -```{r traj, echo = FALSE, message = FALSE, fig.width = 10, eval = TRUE} -# load contact and population data from socialmixr::polymod -polymod <- socialmixr::polymod -contact_data <- socialmixr::contact_matrix( - polymod, - countries = "United Kingdom", - age.limits = c(0, 20, 40), - symmetric = TRUE -) - -# prepare contact matrix -contact_matrix <- t(contact_data$matrix) - -# prepare the demography vector -demography_vector <- contact_data$demography$population -names(demography_vector) <- rownames(contact_matrix) - -# initial conditions: one in every 1 million is infected -initial_i <- 1e-6 -initial_conditions_inf <- c( - S = 1 - initial_i, E = 0, I = initial_i, R = 0, V = 0 -) - -initial_conditions_free <- c( - S = 1, E = 0, I = 0, R = 0, V = 0 -) - -# build for all age groups -initial_conditions <- rbind( - initial_conditions_inf, - initial_conditions_free, - initial_conditions_free -) -rownames(initial_conditions) <- rownames(contact_matrix) - -# prepare the population to model as affected by the epidemic -uk_population <- population( - name = "UK", - contact_matrix = contact_matrix, - demography_vector = demography_vector, - initial_conditions = initial_conditions -) - -# run an epidemic model using `epidemic()` -output_plot <- model_default_cpp( - population = uk_population, - transmissibility = 1.46 / 7.0, - infectiousness_rate = 1.0 / 3.0, - recovery_rate = 1.0 / 7.0, - time_end = 600, increment = 1.0 -) - -filter(output_plot, compartment %in% c("exposed", "infectious")) %>% - ggplot( - aes( - x = time, - y = value, - col = demography_group, - linetype = compartment - ) - ) + - geom_line( - linewidth = 1.2 - ) + - scale_y_continuous( - labels = scales::comma - ) + - scale_colour_brewer( - palette = "Dark2", - name = "Age group" - ) + - expand_limits( - y = c(0, 500e3) - ) + - coord_cartesian( - expand = FALSE - ) + - theme_bw( - base_size = 15 - ) + - theme( - legend.position = "top" - ) + - labs( - x = "Simulation time (days)", - linetype = "Compartment", - y = "Individuals" - ) -``` - - -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: instructor - -By the end of this tutorial, learners should be able to replicate the above image on their own computers. - -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - - -## Simulating disease spread - -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 in `epidemics` 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++](../learners/reference.md#cplusplus) code base. - -In this tutorial, we will use the default model in `epidemics`, `model_default_cpp()` which is an age-structured SEIR model described by a system of [ordinary differential equations](../learners/reference.md#ordinary). For each age group $i$, individuals are classed as either susceptible $S$, infected but not yet infectious $E$, infectious $I$ or recovered $R$. The schematic below shows the processes which describe the flow of individuals between the disease states $S$, $E$, $I$ and $R$ and the key parameters for each process. - -```{r diagram, echo = FALSE, message = FALSE} -DiagrammeR::grViz("digraph { - - # graph statement - ################# - graph [layout = dot, - rankdir = LR, - overlap = true, - fontsize = 10] - - # nodes - ####### - node [shape = square, - fixedsize = true - width = 1.3] - - S - E - I - R - - # edges - ####### - S -> E [label = ' infection \n(transmissibility β)'] - E -> I [label = ' onset of infectiousness \n(infectiousness rate α)'] - I -> R [label = ' recovery \n(recovery rate γ)'] - -}") -``` - - -::::::::::::::::::::::::::::::::::::: callout -### Model parameters : rates - -In ODE models, model parameters are often (but not always) specified as rates. The rate at which an event occurs is the inverse of the average time until that event. For example, in the SEIR model, the recovery rate $\gamma$ is the inverse of the average infectious period. - -We can use knowledge of the natural history of the disease to inform our values of rates. If the average infectious period of an infection is 8 days, then the daily recovery rate is $\gamma = 1/8 = 0.125$. - - -:::::::::::::::::::::::::::::::::::::::::::::::: - - -For each disease state ($S$, $E$, $I$ and $R$) and age group ($i$), we have an ordinary differential equation describing the rate of change with respect to time. - -$$ -\begin{aligned} -\frac{dS_i}{dt} & = - \beta S_i \sum_j C_{i,j} I_j \\ -\frac{dE_i}{dt} &= \beta S_i\sum_j C_{i,j} I_j - \alpha E_i \\ -\frac{dI_i}{dt} &= \alpha E_i - \gamma I_i \\ -\frac{dR_i}{dt} &=\gamma I_i \\ -\end{aligned} -$$ -Individuals in age group ($i$) move from the susceptible state ($S_i$) to the exposed state ($E_i$) via age group specific contact with the infectious individuals in their own and other age groups $\beta S_i \sum_j C_{i,j} I_j$. The contact matrix $C$ allows for heterogeneity in contacts between age groups. They then move to the infectious state at a rate $\alpha$ and recover at a rate $\gamma$. There is no loss of immunity (there are no flows out of the recovered state). - -The model parameters definitions are : - -- transmission rate or transmissibility $\beta$, -- [contact matrix](../learners/reference.md#contact) $C$ containing the frequency of contacts between age groups (a square $i \times j$ matrix), -- infectiousness rate $\alpha$ (preinfectious period ([latent period](../learners/reference.md#latent)) =$1/\alpha$), -- recovery rate $\gamma$ (infectious period = $1/\gamma$). - - -::::::::::::::::::::::::::::::::::::: callout -### Exposed, infected, infectious - -Confusion sometimes arises when referring to the terms 'exposed', 'infected' and 'infectious' in mathematical modelling. Infection occurs after a person has been exposed, but in modelling terms individuals that are 'exposed' are treated as already infected. - -We will use the following definitions for our state variables: - -+ $E$ = Exposed : infected **but not yet** infectious, -+ $I$ = Infectious: infected **and** infectious. -:::::::::::::::::::::::::::::::::::::::::::::::: - - -To generate trajectories using our model, we must prepare the following inputs : - -1. Contact matrix -2. Initial conditions -3. Population structure -4. Model parameters - -### 1. Contact matrix - -Contact matrices can be estimated from surveys or contact data, or synthetic ones can be used. We will use the R package `{socialmixr}` to load in a contact matrix estimated from POLYMOD survey data [(Mossong et al. 2008)](https://doi.org/10.1371/journal.pmed.0050074). - - -::::::::::::::::::::::::::::::::::::: challenge - -## Load contact and population data - -Using the R package `socialmixr`, run the following lines of R code to obtain the contact matrix for the United Kingdom for the year age bins: - -+ age between 0 and 20 years, -+ age between 20 and 40, -+ 40 years and over. - -```r -polymod <- socialmixr::polymod -contact_data <- socialmixr::contact_matrix( - survey = polymod, - countries = "United Kingdom", - age.limits = c(0, 20, 40), - symmetric = TRUE -) -# prepare contact matrix -contact_matrix <- t(contact_data$matrix) -contact_matrix -``` - -:::::::::::::::::::::::: solution - -## Output - -```{r polymod_uk, echo = FALSE, message = FALSE} -polymod <- socialmixr::polymod -contact_data <- socialmixr::contact_matrix( - polymod, - countries = "United Kingdom", - age.limits = c(0, 20, 40), - symmetric = TRUE -) -# prepare contact matrix -contact_matrix <- t(contact_data$matrix) -contact_matrix -``` - - -::::::::::::::::::::::::::::::::: -:::::::::::::::::::::::::::::::::::::::::::::::: - -The result is a square matrix with rows and columns for each age group. Contact matrices can be loaded from other sources, but they must be formatted as a matrix to be used in `epidemics`. - -::::::::::::::::::::::::::::::::::::: callout -### Why would a contact matrix be non-symmetric? - -One of the arguments of the function `contact_matrix()` is `symmetric=TRUE`. This means that the total number of contacts of age group 1 with age group 2, should be the same as the total number of contacts of age group 2 and age group 1 (see the `socialmixr` [vignette](https://cran.r-project.org/web/packages/socialmixr/vignettes/socialmixr.html) for more detail). However, when contact matrices are estimated from surveys or other sources, the *reported* number of contacts may differ by age group resulting in a non-symmetric contact matrix [(Prem et al 2021)](https://doi.org/10.1371/journal.pcbi.1009098). -:::::::::::::::::::::::::::::::::::::::::::::::: - - -### 2. Initial conditions - -The initial conditions are the proportion of individuals in each disease state $S$, $E$, $I$ and $R$ for each age group at time 0. In this example, we have three age groups age between 0 and 20 years, age between 20 and 40 years and over. Let's assume that in the youngest age category, one in a million individuals are infectious, and the remaining age categories are infection free. - -The initial conditions in the first age category are $S(0)=1-\frac{1}{1,000,000}$, $E(0) =0$, $I(0)=\frac{1}{1,000,000}$, $R(0)=0$. This is specified as a vector as follows: - -```{r initial_inf} -initial_i <- 1e-6 -initial_conditions_inf <- c( - S = 1 - initial_i, E = 0, I = initial_i, R = 0, V = 0 -) -``` - -For the age categories that are free from infection, the initial conditions are $S(0)=1$, $E(0) =0$, $I(0)=0$, $R(0)=0$. We specify this as follows, - -```{r initial_free} -initial_conditions_free <- c( - S = 1, E = 0, I = 0, R = 0, V = 0 -) -``` - -We combine the three initial conditions vectors into one matrix, - -```{r initial condtions} -# combine the initial conditions -initial_conditions <- rbind( - initial_conditions_inf, # age group 1 - initial_conditions_free, # age group 2 - initial_conditions_free # age group 3 -) - -# use contact matrix to assign age group names -rownames(initial_conditions) <- rownames(contact_matrix) -initial_conditions -``` - - - - -### 3. Population structure -The population object requires a vector containing the demographic structure of the population. The demographic vector must be a named vector containing the number of individuals in each age group of our given population. In this example, we can extract the demographic information from the `contact_data` object that we obtained using the `socialmixr` package. - -```{r demography} -demography_vector <- contact_data$demography$population -names(demography_vector) <- rownames(contact_matrix) -demography_vector -``` - -To create our population object, we call the function `population()` specifying a name, the contact matrix, the demography vector and the initial conditions. - -```{r population} -uk_population <- population( - name = "UK", - contact_matrix = contact_matrix, - demography_vector = demography_vector, - initial_conditions = initial_conditions -) -``` - - -### 4. Model parameters - -To run our model we need to specify the model parameters: - -- transmissibility $\beta$, -- infectiousness rate $\alpha$ (preinfectious period=$1/\alpha$), -- recovery rate $\gamma$ (infectious period=$1/\gamma$). - -In `epidemics`, we specify the model inputs as : - -- `transmissibility` = $R_0 \gamma$, -- `infectiousness_rate` = $\alpha$, -- `recovery_rate` = $\gamma$, - -We will simulate a strain of influenza with pandemic potential with $R_0=1.46$, a preinfectious period of 3 days and infectious period of 7 days. Therefore our inputs will be: - -- `transmissibility = 1.46 / 7.0`, -- `infectiousness_rate = 1.0 / 3.0`, -- `recovery_rate = 1.0 / 7.0`. - -::::::::::::::::::::::::::::::::::::: callout -### The basic reproduction number $R_0$ -The basic reproduction number, $R_0$, for the SEIR model is: - -$$ R_0 = \frac{\beta}{\gamma}.$$ - -Therefore, we can rewrite transmissibility $\beta$, as: - -$$ \beta = R_0 \gamma.$$ - - -:::::::::::::::::::::::::::::::::::::::::::::::: - - - - - -## Running the model - -::::::::::::::::::::::::::::::::::::: callout -### Running (solving) the model - -For models that are described by ODEs, running the model actually means to solve the system of ODEs. ODEs describe the rate of change in the disease states with respect to time, to find the number of individuals in each of these states, we use numerical integration methods to solve the equations. - -In `epidemics`, the [ODE solver](https://www.boost.org/doc/libs/1_82_0/libs/numeric/odeint/doc/html/index.htm) uses the [Runge-Kutta method](https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods). -:::::::::::::::::::::::::::::::::::::::::::::::: - -Now we are ready to run our model. Let's load the `epidemics` package : - -```{r loading} -library(epidemics) -``` - -Then we specify `time_end=600` to run the model for 600 days. -```{r run_model} -output <- model_default_cpp( - population = uk_population, - transmissibility = 1.46 / 7.0, - infectiousness_rate = 1.0 / 3.0, - recovery_rate = 1.0 / 7.0, - time_end = 600, increment = 1.0 -) -head(output) -``` - -*Note : This model also has the functionality to include vaccination and tracks the number of vaccinated individuals through time. Even though we have not specified any vaccination, there is still a vaccinated compartment in the output (containing no individuals). We will cover the use of vaccination in future tutorials.* - -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. - -```{r visualise, fig.width = 10} -filter(output_plot, compartment %in% c("exposed", "infectious")) %>% - ggplot( - aes( - x = time, - y = value, - col = demography_group, - linetype = compartment - ) - ) + - geom_line( - linewidth = 1.2 - ) + - scale_y_continuous( - labels = scales::comma - ) + - scale_colour_brewer( - palette = "Dark2", - name = "Age group" - ) + - expand_limits( - y = c(0, 500e3) - ) + - coord_cartesian( - expand = FALSE - ) + - theme_bw( - base_size = 15 - ) + - theme( - legend.position = "top" - ) + - labs( - x = "Simulation time (days)", - linetype = "Compartment", - y = "Individuals" - ) -``` - - -::::::::::::::::::::::::::::::::::::: callout -### Time increments - -Note that there is a default argument of `increment = 1`. This relates to the time step of the ODE solver. When the parameters are specified on a daily time-scale and maximum number of time steps (`time_end`) is days, the default time step of the ODE solver one day. - -The choice of increment will depend on the time scale of the parameters, and the rate at which events can occur. In general, the increment should smaller than the fastest event. For example, if parameters are on a monthly time scale, but some events will occur within a month, then the increment should be less than one month. - -:::::::::::::::::::::::::::::::::::::::::::::::: - -## Accounting for uncertainty - -As the epidemic model is [deterministic](../learners/reference.md#deterministic), we have one trajectory for our given parameter values. In practice, we have uncertainty in the value of our parameters. To account for this, we must run our model for different parameter combinations. - -We ran our model with $R_0= 1.5$. However, we believe that $R_0$ follows a normal distribution with mean 1.5 and standard deviation 0.05. To account for uncertainty we will run the model for different values of $R_0$. The steps we will follow to do this are: - -1. Obtain 100 samples from the from a normal distribution - -```{r normal, echo = TRUE} -R0_vec <- rnorm(100, 1.5, 0.05) -``` - -2. Run the model 100 times with $R_0$ equal to a different sample each time - -```{r samples} -output_samples <- Map( - R0_vec, - seq_along(R0_vec), - f = function(x, i) { - # run an epidemic model using `epidemic()` - output <- model_default_cpp( - population = uk_population, - transmissibility = x / 7.0, - infectiousness_rate = 1.0 / 3.0, - recovery_rate = 1.0 / 7.0, - time_end = 600, increment = 1.0 - ) - - # add replicate number and return data - output$replicate <- x - output - } -) - -# combine to prepare for plotting -output_samples <- bind_rows(output_samples) -``` - - -3. Calculate the mean and 95% quantiles of number of infectious individuals across each model simulation and visualise output - -```{r plot, fig.width = 10} -ggplot( - output_samples[output_samples$compartment == "infectious", ], - aes(time, value) -) + - stat_summary(geom = "line", fun = mean) + - stat_summary( - geom = "ribbon", - fun.min = function(z) { - quantile(z, 0.025) - }, - fun.max = function(z) { - quantile(z, 0.975) - }, - alpha = 0.3 - ) + - facet_grid( - cols = vars(demography_group) - ) + - labs( - x = "Simulation time (days)", - y = "Individuals" - ) + - theme_bw( - base_size = 15 - ) -``` - - -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. See [McCabe et al. 2021](https://doi.org/10.1016%2Fj.epidem.2021.100520) to learn about different types of uncertainty in infectious disease modelling. - -## Summary - -In this tutorial, we have learnt how to simulate disease spread using a mathematical model. Once a model has been chosen, the parameters and other inputs must be specified in the correct way to perform model simulations. In the next tutorial, we will consider how to choose the right model for different tasks. - -::::::::::::::::::::::::::::::::::::: keypoints - -- Disease trajectories can be generated using the R package `epidemics` -- Uncertainty should be included in model trajectories using a range of model parameter values - -:::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/learners/setup.md b/learners/setup.md index 47742e35..7d6db2b6 100644 --- a/learners/setup.md +++ b/learners/setup.md @@ -54,8 +54,6 @@ if(!require("pak")) install.packages("pak") new_packages <- c( "EpiNow2", "epiverse-trace/epiparameter", - "socialmixr", - "epiverse-trace/epidemics", "tidyverse" ) @@ -69,8 +67,6 @@ When the installation has finished, you can try to load the packages by pasting ```r library(EpiNow2) library(epiparameter) -library(socialmixr) -library(epidemics) library(tidyverse) ``` diff --git a/renv/profiles/lesson-requirements/renv.lock b/renv/profiles/lesson-requirements/renv.lock index 028832b9..309b42ca 100644 --- a/renv/profiles/lesson-requirements/renv.lock +++ b/renv/profiles/lesson-requirements/renv.lock @@ -39,34 +39,6 @@ ], "Hash": "9b4993e98e0e19da84c168460c032fef" }, - "DiagrammeR": { - "Package": "DiagrammeR", - "Version": "1.0.11", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "RColorBrewer", - "cli", - "dplyr", - "glue", - "htmltools", - "htmlwidgets", - "igraph", - "magrittr", - "purrr", - "readr", - "rlang", - "rstudioapi", - "scales", - "stringr", - "tibble", - "tidyr", - "viridisLite", - "visNetwork" - ], - "Hash": "584c1e1cbb6f9b6c3b0f4ef0ad960966" - }, "EpiNow2": { "Package": "EpiNow2", "Version": "1.4.0", @@ -546,20 +518,6 @@ ], "Hash": "59351f28a81f0742720b85363c4fdd61" }, - "deSolve": { - "Package": "deSolve", - "Version": "1.40", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "grDevices", - "graphics", - "methods", - "stats" - ], - "Hash": "0a861334beb4eb8ca0d24a27b28b6679" - }, "desc": { "Package": "desc", "Version": "1.4.3", @@ -674,30 +632,6 @@ ], "Hash": "bb0eec2fe32e88d9e2836c2f73ea2077" }, - "epidemics": { - "Package": "epidemics", - "Version": "0.0.0.9000", - "Source": "GitHub", - "RemoteType": "github", - "RemoteUsername": "epiverse-trace", - "RemoteRepo": "epidemics", - "RemoteRef": "main", - "RemoteSha": "f7e33b594768fb1fdac3fb97f9c075c7f9e9ce76", - "RemoteHost": "api.github.com", - "Requirements": [ - "BH", - "Rcpp", - "RcppEigen", - "checkmate", - "cli", - "data.table", - "deSolve", - "glue", - "stats", - "utils" - ], - "Hash": "3799aa7424ed199ea2f83a439655f1b1" - }, "epiparameter": { "Package": "epiparameter", "Version": "0.0.0.9000", @@ -1003,13 +937,6 @@ ], "Hash": "d6db1667059d027da730decdc214b959" }, - "grates": { - "Package": "grates", - "Version": "1.1.0", - "Source": "Repository", - "Repository": "CRAN", - "Hash": "c937fa4cc110a4aabae986a6393dfb15" - }, "gridExtra": { "Package": "gridExtra", "Version": "2.3", @@ -1102,21 +1029,6 @@ ], "Hash": "2d7b3857980e0e0d0a1fd6f11928ab0f" }, - "htmlwidgets": { - "Package": "htmlwidgets", - "Version": "1.6.4", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "grDevices", - "htmltools", - "jsonlite", - "knitr", - "rmarkdown", - "yaml" - ], - "Hash": "04291cc45198225444a397606810ac37" - }, "httr": { "Package": "httr", "Version": "1.4.7", @@ -1143,43 +1055,6 @@ ], "Hash": "99df65cfef20e525ed38c3d2577f7190" }, - "igraph": { - "Package": "igraph", - "Version": "2.0.1.1", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "Matrix", - "R", - "cli", - "cpp11", - "grDevices", - "graphics", - "lifecycle", - "magrittr", - "methods", - "pkgconfig", - "rlang", - "stats", - "utils" - ], - "Hash": "fb2999614d40fe7fd61cf569b66a2dbc" - }, - "incidence2": { - "Package": "incidence2", - "Version": "2.2.3", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "data.table", - "grDevices", - "grates", - "pillar", - "utils" - ], - "Hash": "0e1c66f6d72eacacbd8fe6ba1ed85cc9" - }, "inline": { "Package": "inline", "Version": "0.3.19", @@ -1633,7 +1508,7 @@ "Package": "ragg", "Version": "1.2.7", "Source": "Repository", - "Repository": "RSPM", + "Repository": "https://carpentries.r-universe.dev", "Requirements": [ "systemfonts", "textshaping" @@ -1925,7 +1800,7 @@ "Package": "stringi", "Version": "1.8.3", "Source": "Repository", - "Repository": "RSPM", + "Repository": "https://carpentries.r-universe.dev", "Requirements": [ "R", "stats", @@ -2165,24 +2040,6 @@ ], "Hash": "c826c7c4241b6fc89ff55aaea3fa7491" }, - "visNetwork": { - "Package": "visNetwork", - "Version": "2.1.2", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "grDevices", - "htmltools", - "htmlwidgets", - "jsonlite", - "magrittr", - "methods", - "stats", - "utils" - ], - "Hash": "3e48b097e8d9a91ecced2ed4817a678d" - }, "vroom": { "Package": "vroom", "Version": "1.6.5", @@ -2209,19 +2066,6 @@ ], "Hash": "390f9315bc0025be03012054103d227c" }, - "webshot": { - "Package": "webshot", - "Version": "0.5.5", - "Source": "Repository", - "Repository": "CRAN", - "Requirements": [ - "R", - "callr", - "jsonlite", - "magrittr" - ], - "Hash": "16858ee1aba97f902d24049d4a44ef16" - }, "withr": { "Package": "withr", "Version": "3.0.0", diff --git a/tutorials.Rproj b/tutorials-early.Rproj similarity index 100% rename from tutorials.Rproj rename to tutorials-early.Rproj