diff --git a/404.html b/404.html index ad6be4a4..6b402fa6 100644 --- a/404.html +++ b/404.html @@ -73,7 +73,7 @@ -
@@ -149,7 +149,40 @@

+ + + +
+ + +
+ + @@ -241,8 +274,8 @@

Page not found

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -263,7 +296,7 @@

Page not found

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/404.html", "identifier": "https://epiverse-trace.github.io/tutorials/404.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/CODE_OF_CONDUCT.html b/CODE_OF_CONDUCT.html index e2d224b2..d6a79a6e 100644 --- a/CODE_OF_CONDUCT.html +++ b/CODE_OF_CONDUCT.html @@ -73,7 +73,7 @@ - @@ -147,7 +147,34 @@

+ + + + + + @@ -211,7 +238,7 @@


Contributor Code of Conduct

-

Last updated on 2023-10-26 | +

Last updated on 2023-10-31 | Edit this page

@@ -273,8 +300,8 @@

Contributor Code of Conduct

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -295,8 +322,8 @@

Contributor Code of Conduct

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/CODE_OF_CONDUCT.html", "identifier": "https://epiverse-trace.github.io/tutorials/CODE_OF_CONDUCT.html", - "dateCreated": "2023-10-30", - "dateModified": "2023-10-26", + "dateCreated": "2023-10-31", + "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/LICENSE.html b/LICENSE.html index e0f8c960..52a25824 100644 --- a/LICENSE.html +++ b/LICENSE.html @@ -73,7 +73,7 @@ - @@ -147,7 +147,34 @@

+ + + + + + @@ -211,7 +238,7 @@


Licenses

-

Last updated on 2023-10-26 | +

Last updated on 2023-10-31 | Edit this page

@@ -321,8 +348,8 @@

Licenses

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -343,8 +370,8 @@

Licenses

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/LICENSE.html", "identifier": "https://epiverse-trace.github.io/tutorials/LICENSE.html", - "dateCreated": "2023-10-30", - "dateModified": "2023-10-26", + "dateCreated": "2023-10-31", + "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/aio.html b/aio.html index 32bf06f6..64730e3f 100644 --- a/aio.html +++ b/aio.html @@ -93,7 +93,7 @@ More @@ -181,7 +181,43 @@

+ + + + + +
+ + +
+ + + @@ -244,11 +280,11 @@

-

Content from Lesson title

+

Content from Simulating transmission


-

Last updated on 2023-10-26 | +

Last updated on 2023-10-31 | - Edit this page

+ Edit this page

@@ -260,7 +296,8 @@

Overview

Questions

    -
  • What questions will this lesson cover?
  • +
  • How do I generate predictions of disease trajectories?
  • +
  • What inputs are needed for a model simulation?
@@ -269,9 +306,11 @@

Questions

Objectives

+

Using the R package epidemics, learn how to:

    -
  • Objective 1
  • -
  • Objective 2
  • +
  • load an existing model structure,
  • +
  • load an existing social contact matrix,
  • +
  • run a model simulation.
@@ -286,42 +325,230 @@

Objectives

Prerequisites

-

List (and hyperlink) the lessons/packages which need to be covered -before this lesson

+

This tutorial has the following concept dependencies:

+

Modelling : Components of +infectious disease models e.g. state variables, parameters, initial +conditions, Ordinary differential equations.

+

Epidemic theory : Transmission, Reproduction +number.

Introduction


-

Introductory text

- -

Section header +

Mathematical models are useful tools for generating future +trajectories of disease spread. Models can be used to evaluate the +implementation of non-pharmaceutical and pharmaceutical interventions +while accounting for factors such as age.

+

In this tutorial, we will use the R package {epidemics} +to generate trajectories of influenza spread. By the end of this +tutorial, you will be able to generate the trajectory below showing the +number of infectious individuals in different age categories through +time.

+

The first step is to install the R packages +epidemics.

+
+

R +

+
+if (!require("pak")) install.packages("pak")
+pak::pak("epiverse-trace/epidemics")
+
+

Model structures


-

Lesson content

-
+

To generate predictions of infectious disease trajectories, we must +first select a mathematical model to use.

+

There is a library of models to choose from in +epidemics. Models are prefixed with epidemic and suffixed +by the infection name. In this tutorial, we will use the default +epidemic model, epidemic_default() which is described in +the next section.

+
+
+ +
+
+

Check model equations +

+
+

When using existing model structures always check the model +assumptions. Ask questions such as:

+
    +
  • How is transmission modelled? e.g. direct or indirect, airborne or +vector-borne
  • +
  • What interventions are modelled?
  • +
  • What state variables are there and how do they relate to assumptions +about infection?
  • +
+

There can be subtle differences in model structures for the same +infection or outbreak type which can be missed without studying the +equations.

+
+
+
+
+

An epidemic model for pandemic influenza +

+

We want to generate disease trajectories of an influenza strain with +pandemic potential. We will use the default epidemic model in +epidemics, an age-structured SEIR model described by a +system of ordinary differential equations. For each age group \(i\), individuals are classed as either +susceptible \(S\), infected but not yet +infectious \(E\), infectious \(I\) or recovered \(R\).

+

The model parameters and equations are as follows :

+
    +
  • transmission rate \(\beta\),
  • +
  • contact matrix \(C\) containing the +frequency of contacts between age groups (a square \(i \times j\) matrix),
  • +
  • rate of transition from exposed to infectious \(\alpha\) (preinfectious period=\(1/\alpha\)),
  • +
  • recovery rate \(\gamma\) +(infectious period = \(1/\gamma\)).
  • +
+

\[ +\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} +\]

+

The contact matrix is a square matrix consisting of +rows/columns equal to the number age groups. Each element represents the +frequency of contacts between age groups. If we believe that +transmission of an infection is driven by contact, and that contact +rates are very different for different age groups, then specifying a +contact matrix allows us to account for age specific rates of +transmission.

+

From the model structure we see that :

+
    +
  • the contact matrix \(C\) allows for +heterogeneity in contacts between age groups,
  • +
  • there is no loss of immunity (there are no flows out of the +recovered state).
  • +
+

This model also has the functionality to include vaccination and +tracks the number of vaccinated individuals through time. We will cover +the use of interventions in future tutorials.

+
+
+ +
+
+

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 need the following :

+
    +
  1. parameter values,
  2. +
  3. contact matrix,
  4. +
  5. demographic structure,
  6. +
  7. initial conditions.
  8. +
+
+

Model parameters +

+
+

To run our model we need to specify the model parameters:

+
    +
  • transmission rate \(\beta\),
  • +
  • rate of transition from exposed to infectious \(\alpha\) (preinfectious period=\(1/\alpha\)),
  • +
  • recovery rate \(\gamma\) +(infectious period=\(1/\gamma\)).
  • +
+

We will learn how to specify the contact matrix \(C\) in the next section.

+

We will simulate a strain of influenza with pandemic potential with +\(R_0=1.5\), a preinfectious period of +3 days and infectious period of 7 days.

+

In epidemics, we use the function +infection() to create an infection object containing the +values of, \(R_0\), the preinfectious +period (\(1/\alpha\)) and the +infectious period (\(1/\gamma\)) as +follows.

+
+

R +

+
+influenza <- infection(
+  name = "influenza",
+  r0 = 1.5,
+  preinfectious_period = 3,
+  infectious_period = 7
+)
+
+
+
+ +
+
+

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 the transmission rate, \(\beta\), as:

+

\[ \beta = R_0 \gamma.\]

+
+
+
+ +
+

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).

+
-
-

Challenge 1 : can the learner run existing -code +
+

Load contact and population data

-

Load contact and population data from socialmixr::polymod

-
+

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(
-  polymod,
+  survey = polymod,
   countries = "United Kingdom",
   age.limits = c(0, 20, 40),
   symmetric = TRUE
 )
-contact_data
+# prepare contact matrix +contact_matrix <- t(contact_data$matrix) +contact_matrix
@@ -338,136 +565,1006 @@

OUTPUT

-
Using POLYMOD social contact data. To cite this in a publication, use the 'get_citation()' function
+
                 
+contact.age.group     [,1]     [,2]     [,3]
+          [0,20)  7.883663 2.794154 1.565665
+          [20,40) 3.120220 4.854839 2.624868
+          40+     3.063895 4.599893 5.005571
+
+

+

+
+
+

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 in the correct format to be used in epidemics.

+
+
+ +
+
+

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 +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).

+
+
+
+ +

Generating trajectories +

+
+

We have prepared our parameter values, contact matrix and demography +vector. Now we must set the initial conditions, prepare the population +and run the model.

+
+

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_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_conditions_free <- c(
+  S = 1, E = 0, I = 0, R = 0, V = 0
+)
+
+

We combine the three initial conditions vectors into one matrix,

+
+

R +

+
+# build for all age groups
+initial_conditions <- rbind(
+  initial_conditions_inf,
+  initial_conditions_free,
+  initial_conditions_free
+)
+rownames(initial_conditions) <- rownames(contact_matrix)
+initial_conditions
+
+
+

OUTPUT +

+
               S E     I R V
+[0,20)  0.999999 0 1e-06 0 0
+[20,40) 1.000000 0 0e+00 0 0
+40+     1.000000 0 0e+00 0 0
+
+
+
+

Running the model +

+

To run the model we need the following inputs:

+
    +
  • an infection object,
  • +
  • a population object,
  • +
  • an optional number of time steps.
  • +
+

We have already created our infection object influenza. +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_vector <- contact_data$demography$population
+names(demography_vector) <- rownames(contact_matrix)
+demography_vector

OUTPUT

-
Removing participants that have contacts without age information. To change this behaviour, set the 'missing.contact.age' option
+
  [0,20)  [20,40)      40+ 
+14799290 16526302 28961159 
+
+

To create our population object, we call the function +population() specifying a name, the contact matrix, the +demography vector and the initial conditions.

+
+

R +

+
+uk_population <- population(
+  name = "UK",
+  contact_matrix = contact_matrix,
+  demography_vector = demography_vector,
+  initial_conditions = initial_conditions
+)
+
+

No we are ready to run our model. We will specify +time_end=600 to run the model for 600 days.

+
+

R +

+
+output <- epidemic_default_cpp(
+  population = uk_population,
+  infection = influenza,
+  time_end = 600
+)
+head(output)

OUTPUT

-
$matrix
-      contact.age.group
-         [0,20)  [20,40)      40+
-  [1,] 7.883663 3.120220 3.063895
-  [2,] 2.794154 4.854839 4.599893
-  [3,] 1.565665 2.624868 5.005571
-
-$demography
-   age.group population proportion year
-1:    [0,20)   14799290  0.2454816 2005
-2:   [20,40)   16526302  0.2741283 2005
-3:       40+   28961159  0.4803901 2005
-
-$participants
-   age.group participants proportion
-1:    [0,20)          404  0.3996044
-2:   [20,40)          248  0.2453017
-3:       40+          359  0.3550940
+
   time demography_group compartment    value
+1:    0           [0,20) susceptible 14799275
+2:    0          [20,40) susceptible 16526302
+3:    0              40+ susceptible 28961159
+4:    0           [0,20)     exposed        0
+5:    0          [20,40)     exposed        0
+6:    0              40+     exposed        0
+
+

Our model output consists of the number of individuals in each +compartment in each age group through time. We can visualise the +infectious individuals only (those in the \(I\) class) through time.

+
+

R +

+
+ggplot(output[compartment == "infectious", ]) +
+  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,
+    name = "Infectious indivduals"
+  ) +
+  labs(
+    x = "Model time (days)"
+  ) +
+  theme_classic() +
+  theme(
+    legend.position = "top"
+  ) +
+  theme_grey(
+    base_size = 15
+  )
+
+
+
+ +
+
+

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 and +maximum number of time steps is days, the default increment is 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, 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
  2. +
+
+

R +

+
+R0_vec <- rnorm(100, 1.5, 0.05)
-

Section header +
    +
  1. Run the model 100 times with \(R_0\) equal to a different sample each +time
  2. +
+
+

R +

+
+output_samples <- Map(
+ R0_vec,
+  seq_along(R0_vec),
+  f = function(x, i) {
+  # create infection object for R0 value
+    influenza <- infection(
+      name = "influenza",
+      r0 = x,
+      preinfectious_period = 3,
+      infectious_period = 7
+    )
+
+    # run an epidemic model using `epidemic()`
+    output <- epidemic_default_cpp(
+      population = uk_population,
+      infection = influenza,
+      time_end = 600, increment = 1.0
+    )
+
+    # extract infectious individuals 
+    output <- output[compartment == "infectious"]
+
+    # assign scenario number
+    output[, c("scenario", "R") := list(i, x)]
+
+    output
+  }
+)
+
+# combine to prepare for plotting
+output_samples <- bind_rows(output_samples)
+
+
    +
  1. Calculate the mean and 95% quantiles of number of infectious +individuals across each model simulation and visualise output
  2. +
+
+

R +

+
+ggplot(output_samples ,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)
+  ) +
+  theme_grey(
+    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.

+ +

Summary


-

Lesson content

-
+

In this tutorial, we have learnt how to generate disease trajectories +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 +
  • +
  • Contact matrices can be estimated from different sources
  • +
  • Include uncertainty in model trajectories
  • +
+
+
+
+ +

Content from Choosing an appropriate model

+
+

Last updated on 2023-10-31 | + + Edit this page

+
+ +
+
+

Overview

+
+
+
+
+

Questions

+
    +
  • How do I choose a model for my task?
  • +
+
+
+
+
+
+
+

Objectives

+
    +
  • Learn how to access the model library in epidemics +
  • +
  • Understand the model requirements for a question
  • +
+
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
    +
  • Complete tutorial ‘Simulating transmission’
  • +
+
+
+
+

Introduction +

+
+

Using mathematical models in outbreak analysis does not necessarily +require developing a new model. There are existing 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 generate predictions for a given scenario.

+ +
+

Choosing a model +

+

When deciding whether an existing model can be used, we must consider +:

+
    +
  • 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.

+
    +
  • Do we need a deterministic or 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.

+
    +
  • 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.

+
    +
  • 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 will discuss interventions in detail in the +next tutorial.

+
+
+

Available models +

+

The R package epidemics contains functions to run +existing models. For details on the models that are available, see the +package vignettes. +To learn how to run the models in R, read the documentation using +?epidemics::epidemic_ebola. Remember to use the ‘Check +model equation’ questions to help your understanding of an existing +model.

+
+
+
-
-

Explainer +
+

Check model equations

-

Add additional maths (or epi) content for novice learners

+
    +
  • How is transmission modelled? e.g. direct or indirect, airborne or +vector-borne
  • +
  • What interventions are modelled?
  • +
  • What state variables are there and how do they relate to assumptions +about infection?
  • +

-
+
+

Challenge +

+
+
-
-

Challenge 2 : edit code/answer a question +
+

What model?

-

Load contact and population data for Poland from socialmixr::polymod -using the following age bins:

+

You have been asked to explore the variation in numbers of infected +individuals in the early stages of an Ebola outbreak.

+

Which of the following models would be an appropriate choice for this +task:

    -
  • [0,15)
  • -
  • [15, 50)
  • -
  • 50 +
  • +
  • epidemic_default

  • +
  • epidemic_ebola

-
+
- -
+
-
-

R +

Consider the following questions:

+
+
+ +
+
+

Checklist

-
-polymod <- socialmixr::polymod
-contact_data <- socialmixr::contact_matrix(
-  polymod,
-  countries = "Poland",
-  age.limits = c(0, 15, 50),
-  symmetric = TRUE
-)
+
+
    +
  • 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?
  • +
+
+
+
+

+
+
+
+
+
+ +
+
+
    +
  • 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 +
  • +
+
+

+epidemic_default +

+

A deterministic SEIR model with age specific direct transmission.

+

The model is capable of predicting an Ebola type outbreak, but as the +model is deterministic, we are not able to explore stochastic variation +in the early stages of the outbreak.

+
+
+

+epidemic_ebola +

+

A stochastic SEIHFR (Susceptible, Exposed, Infectious, Hospitalised, +Funeral, Removed) model that was developed specifically for infection +with Ebola.

+

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.

+
+
+
+
+
+
+
+ +
+
+

Keypoints +

+
+
    +
  • Existing models can be used for new questions
  • +
  • Check that a model has appropriate assumptions about transmission, +outbreak potential, outcomes and interventions
  • +
+
+
+
+ +

Content from Modelling interventions

+
+

Last updated on 2023-10-31 | + + Edit this page

+
+ +
+
+

Overview

+
+
+
+
+

Questions

+
    +
  • How do I investigate the effect of interventions on disease +trajectories?
  • +
+
+
+
+
+
+
+

Objectives

+
    +
  • Learn how to implement pharmaceutical and non-pharmaceutical +interventions
  • +
+
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
    +
  • Complete tutorial ‘Simulating transmission’
  • +
+

This tutorial has the following concept dependencies:

+

Outbreak response : Intervention +types.

+
+
+
+

Introduction +

+
+

Mathematical models can be used to generate predictions for the +implementation of non-pharmaceutical and pharmaceutical interventions at +different stages of an outbreak. In this tutorial, we will introduce how +to include different interventions in models.

+ +

Non-pharmaceutical interventions +

+
+

Non-pharmaceutical interventions (NPIs) are measures put in place to +reduce transmission that do not include taking medicine or vaccines. +NPIs aim reduce contact between infectious and susceptible individuals. +For example, washing hands, wearing masks and closures of school and +workplaces.

+

In mathematical modelling, we must make assumptions about how NPIs +will affect transmission. This may include adding additional disease +states or reducing the value of relevant parameters.

+
+

Effect of school closures on COVID-19 spread +

+

We want to investigate the effect of school closures on reducing the +number of individuals infectious with COVID-19 through time. We assume +that a school closure will reduce the frequency of contacts within and +between different age groups.

+

Using an SEIR model (epidemic_default() in the R package +{epidemics}) we set \(R_0 = +2.7\), preinfectious period \(= +4\) and the infectious_period \(= +5.5\) (parameters adapted from Davies et +al. (2020)). We load a contact matrix with age bins 0-18, 18-65, 65 +years and older using socialmixr and assume that one in +every 1 million in each age group is infectious at the start of the +epidemic.

+

We will assume that school closures will reduce the contacts between +school aged children (aged 0-15) by 0.5, and will cause a small +reduction (0.01) in the contacts between adults (aged 15 and over).

+
+
+
+
+

Effect of interventions on contacts +

+
+

The contact matrix is scaled down by proportions for the period in +which the intervention is in place. To explain the reduction, consider a +contact matrix for two age groups with equal number of contacts:

OUTPUT

-
Using POLYMOD social contact data. To cite this in a publication, use the 'get_citation()' function
+
     [,1] [,2]
+[1,]    1    1
+[2,]    1    1
+

If the reduction is 50% in group 1 and 10% in group 2, the contact +matrix during the intervention will be:

OUTPUT

-
Removing participants that have contacts without age information. To change this behaviour, set the 'missing.contact.age' option
+
     [,1] [,2]
+[1,] 0.25 0.45
+[2,] 0.45 0.81
-
+

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\)).

+
+
+
+

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

-contact_data
+rownames(contact_matrix)

OUTPUT

-
$matrix
-      contact.age.group
-          [0,15)   [15,50)      50+
-  [1,] 8.4882943  5.047958 1.765826
-  [2,] 1.5998125 14.049041 3.624419
-  [3,] 0.9468591  6.132289 4.314050
-
-$demography
-   age.group population proportion year
-1:    [0,15)    6372248  0.1661054 2005
-2:   [15,50)   20106632  0.5241197 2005
-3:       50+   11883794  0.3097749 2005
-
-$participants
-   age.group participants proportion
-1:    [0,15)          299  0.2960396
-2:   [15,50)          469  0.4643564
-3:       50+          242  0.2396040
+
[1] "[0,15)"  "[15,65)" "65+"    
+
+

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 +

+
+close_schools <- intervention(
+  name = "School closure",
+  type = "contacts",
+  time_begin = 50,
+  time_end = 50 + 100,
+  reduction = matrix(c(0.5, 0.01, 0.01))
+)
+
+

To run the model with an intervention we set +intervention = list(contacts = close_schools) as +follows:

+
+

R +

+
+output_school <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  intervention = list(contacts = close_schools),
+  time_end = 300, increment = 1.0
+)
+
+

We see that with the intervention (solid line) in place, the +infection still spreads through the population, though the epidemic peak +is smaller than the baseline with no intervention in place (dashed +line).

+
+
+
+

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 transmission rate +\(\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)

+

We create an intervention object with type = rate and +reduction = 0.161. Using parameters adapted from Li et al. 2020 +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 +

+
+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 <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  intervention = list(beta = mask_mandate),
+  time_end = 300, increment = 1.0
+)
+
+

Pharmaceutical interventions +

+
+

Models can be used to investigate the effect of pharmaceutical +interventions, such as vaccination. In this case, it is useful to add +another disease state to track the number of vaccinated individuals +through time. The diagram below shows an SEIRV model where susceptible +individuals are vaccinated and then move to the \(V\) class.

+

The equations describing this model are as follows:

+

\[ +\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\)). The SEIR components of these +equations are described in the tutorial Simulating transmission.

+

To explore the effect of vaccination we need to create a vaccination +object. As vaccination is age group specific, we must pass an age groups +specific vaccination rate \(\nu\) and +age group specific start and end times of the vaccination program. Here +we will assume all age groups are vaccinated at the same rate and that +the vaccination program starts on day 40 and is in place for 150 +days.

+
+

R +

+
+# 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 <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  vaccination = vaccinate,
+  time_end = 300, increment = 1.0
+)
+
+

Here we see that the total number of infectious individuals when +vaccination is in place is much lower compared to school closures and +mask wearing interventions.

+

Summary +

+
+

Modelling interventions requires assumptions of how interventions +affect model parameters such as contact matrices or parameter values. +Next we want quantify the effect of an interventions. In the next +tutorial, we will learn how to compare intervention scenarios against +each other.

+
+
+ +
+
+

Keypoints +

+
+
    +
  • Different types of intervention can be implemented using +mathematical modelling
  • +
+ +

Content from Comparing public health outcomes of interventions

+
+

Last updated on 2023-10-31 | + + Edit this page

+
+ +
+
+

Overview

+
+
+
+
+

Questions

+
    +
  • How can I quantify the effect of an intervention?
  • +
+
+
+
+
+
+
+

Objectives

+
    +
  • Understand how to compare intervention scenarios
  • +
+
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
    +
  • Complete tutorials ‘Simulating transmission’ and ‘Modelling +interventions’
  • +
+

This tutorial has the following concept dependencies:

+

Outbreak response : Intervention +types.

+
+
+
+

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.
  • +

Vacamole model +

+
+

The Vacamole model is a deterministic model based on a system of ODEs +in Ainslie +et al. 2022. 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.

+

See ?epidemics::epidemic_vacamole for detail on how to +run the model.

+

Comparing scenarios +

+
+

Coming soon

+

Challenge +

+
+

Coming soon

+ + + + + + + + + @@ -511,8 +1609,8 @@

KeypointsCC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -534,7 +1632,7 @@

Keypoints +Epiverse-TRACE: Comparing public health outcomes of interventions +
+ Epiverse-TRACE +
+ +
+
+ + + + + +
+
+

Comparing public health outcomes of interventions

+

Last updated on 2023-10-31 | + + Edit this page

+ + + +
+ +
+ + + +
+

Overview

+
+
+
+
+

Questions

+
  • How can I quantify the effect of an intervention?
  • +
+
+
+
+
+
+

Objectives

+
  • Understand how to compare intervention scenarios
  • +
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
  • Complete tutorials ‘Simulating transmission’ and ‘Modelling +interventions’
  • +

This tutorial has the following concept dependencies:

+

Outbreak response : Intervention +types.

+
+
+
+

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.
  • +

Vacamole model +

+

The Vacamole model is a deterministic model based on a system of ODEs +in Ainslie +et al. 2022. 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.

+

See ?epidemics::epidemic_vacamole for detail on how to +run the model.

+

Comparing scenarios +

+

Coming soon

+

Challenge +

+

Coming soon

+ + + + + + + + + +
+
+ +
+
+

Keypoints +

+
+
  • The counter factual scenario must be defined to make +comparisons
  • +
+
+
+ +
+
+ + +
+
+ + + diff --git a/fig/compare-interventions-rendered-unnamed-chunk-1-1.png b/fig/compare-interventions-rendered-unnamed-chunk-1-1.png new file mode 100644 index 00000000..9e03b7a4 Binary files /dev/null and b/fig/compare-interventions-rendered-unnamed-chunk-1-1.png differ diff --git a/fig/model-choices-rendered-diagram-1.png b/fig/model-choices-rendered-diagram-1.png new file mode 100644 index 00000000..eb18a7f6 Binary files /dev/null and b/fig/model-choices-rendered-diagram-1.png differ diff --git a/fig/model-choices-rendered-unnamed-chunk-1-1.png b/fig/model-choices-rendered-unnamed-chunk-1-1.png new file mode 100644 index 00000000..5a803301 Binary files /dev/null and b/fig/model-choices-rendered-unnamed-chunk-1-1.png differ diff --git a/fig/modelling-interventions-rendered-diagram_SEIRV-1.png b/fig/modelling-interventions-rendered-diagram_SEIRV-1.png new file mode 100644 index 00000000..d684c708 Binary files /dev/null and b/fig/modelling-interventions-rendered-diagram_SEIRV-1.png differ diff --git a/fig/modelling-interventions-rendered-plot_masks-1.png b/fig/modelling-interventions-rendered-plot_masks-1.png new file mode 100644 index 00000000..cad5366a Binary files /dev/null and b/fig/modelling-interventions-rendered-plot_masks-1.png differ diff --git a/fig/modelling-interventions-rendered-plot_school-1.png b/fig/modelling-interventions-rendered-plot_school-1.png new file mode 100644 index 00000000..af037670 Binary files /dev/null and b/fig/modelling-interventions-rendered-plot_school-1.png differ diff --git a/fig/modelling-interventions-rendered-plot_vaccinate-1.png b/fig/modelling-interventions-rendered-plot_vaccinate-1.png new file mode 100644 index 00000000..a2ef03e7 Binary files /dev/null and b/fig/modelling-interventions-rendered-plot_vaccinate-1.png differ diff --git a/fig/simulating-transmission-rendered-diagram-1.png b/fig/simulating-transmission-rendered-diagram-1.png new file mode 100644 index 00000000..ab75590d Binary files /dev/null and b/fig/simulating-transmission-rendered-diagram-1.png differ diff --git a/fig/simulating-transmission-rendered-plot-1.png b/fig/simulating-transmission-rendered-plot-1.png new file mode 100644 index 00000000..d025a235 Binary files /dev/null and b/fig/simulating-transmission-rendered-plot-1.png differ diff --git a/fig/simulating-transmission-rendered-traj-1.png b/fig/simulating-transmission-rendered-traj-1.png new file mode 100644 index 00000000..61a237dd Binary files /dev/null and b/fig/simulating-transmission-rendered-traj-1.png differ diff --git a/fig/simulating-transmission-rendered-visualise-1.png b/fig/simulating-transmission-rendered-visualise-1.png new file mode 100644 index 00000000..61a237dd Binary files /dev/null and b/fig/simulating-transmission-rendered-visualise-1.png differ diff --git a/images.html b/images.html index ecf51eae..8b8c170a 100644 --- a/images.html +++ b/images.html @@ -93,7 +93,7 @@ More @@ -181,7 +181,43 @@

+ + + + + +
+ + +
+ + + @@ -244,8 +280,33 @@

-

Lesson title

-
+

Simulating transmission

+
+

Figure 1

+

+

Figure 2

+

+

Figure 3

+

+

Figure 4

+

Choosing an appropriate model

+
+

Figure 1

+

+

Figure 2

+

Modelling interventions

+
+

Figure 1

+

+

Figure 2

+

+

Figure 3

+

+

Figure 4

+

Comparing public health outcomes of interventions

+
+

Figure 1

+

@@ -270,8 +331,8 @@

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -293,7 +354,7 @@

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/images.html", "identifier": "https://epiverse-trace.github.io/tutorials/images.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/index.html b/index.html index 5c18bd29..e2d952d7 100644 --- a/index.html +++ b/index.html @@ -73,7 +73,7 @@ -
@@ -158,7 +158,34 @@

+ + + + + + @@ -206,11 +233,11 @@

Summary and Setup

@@ -242,11 +269,11 @@

any links that you are not going to use. -->

@@ -268,8 +295,8 @@

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -290,7 +317,7 @@

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/index.html", "identifier": "https://epiverse-trace.github.io/tutorials/index.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/instructor-notes.html b/instructor-notes.html index 67319166..f9248878 100644 --- a/instructor-notes.html +++ b/instructor-notes.html @@ -93,7 +93,7 @@ More @@ -181,7 +181,43 @@

+ + + + + +
+ + +
+ + + @@ -277,8 +313,8 @@

Instructor Notes

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -300,7 +336,7 @@

Instructor Notes

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/instructor-notes.html", "identifier": "https://epiverse-trace.github.io/tutorials/instructor-notes.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/instructor/404.html b/instructor/404.html index eb783075..e2faf626 100644 --- a/instructor/404.html +++ b/instructor/404.html @@ -73,7 +73,7 @@ - @@ -149,7 +149,40 @@

+ + + +
+ + +
+ + @@ -241,8 +274,8 @@

Page not found

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -263,7 +296,7 @@

Page not found

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/instructor/404.html", "identifier": "https://epiverse-trace.github.io/tutorials/instructor/404.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/instructor/CODE_OF_CONDUCT.html b/instructor/CODE_OF_CONDUCT.html index d9fdf827..a33d11f7 100644 --- a/instructor/CODE_OF_CONDUCT.html +++ b/instructor/CODE_OF_CONDUCT.html @@ -146,7 +146,34 @@

+ + + + + +

Contributor Code of Conduct

-

Last updated on 2023-10-26 | +

Last updated on 2023-10-31 | Edit this page

@@ -274,8 +301,8 @@

Contributor Code of Conduct

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -296,8 +323,8 @@

Contributor Code of Conduct

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/instructor/CODE_OF_CONDUCT.html", "identifier": "https://epiverse-trace.github.io/tutorials/instructor/CODE_OF_CONDUCT.html", - "dateCreated": "2023-10-30", - "dateModified": "2023-10-26", + "dateCreated": "2023-10-31", + "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/instructor/LICENSE.html b/instructor/LICENSE.html index 425be513..9f15dbcc 100644 --- a/instructor/LICENSE.html +++ b/instructor/LICENSE.html @@ -146,7 +146,34 @@

+ + + + + +

Licenses

-

Last updated on 2023-10-26 | +

Last updated on 2023-10-31 | Edit this page

@@ -322,8 +349,8 @@

Licenses

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -344,8 +371,8 @@

Licenses

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/instructor/LICENSE.html", "identifier": "https://epiverse-trace.github.io/tutorials/instructor/LICENSE.html", - "dateCreated": "2023-10-30", - "dateModified": "2023-10-26", + "dateCreated": "2023-10-31", + "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/instructor/aio.html b/instructor/aio.html index f14221c1..34ab31ca 100644 --- a/instructor/aio.html +++ b/instructor/aio.html @@ -179,7 +179,43 @@

+ + + + + +
+ + +
+ + +
+
+ @@ -242,12 +278,12 @@

-

Content from Lesson title

+

Content from Simulating transmission


-

Last updated on 2023-10-26 | +

Last updated on 2023-10-31 | - Edit this page

-

Estimated time 15 minutes

+ Edit this page

+

Estimated time 75 minutes

@@ -259,7 +295,8 @@

Overview

Questions

    -
  • What questions will this lesson cover?
  • +
  • How do I generate predictions of disease trajectories?
  • +
  • What inputs are needed for a model simulation?
@@ -268,9 +305,11 @@

Questions

Objectives

+

Using the R package epidemics, learn how to:

    -
  • Objective 1
  • -
  • Objective 2
  • +
  • load an existing model structure,
  • +
  • load an existing social contact matrix,
  • +
  • run a model simulation.
@@ -285,16 +324,28 @@

Objectives

Prerequisites

-

List (and hyperlink) the lessons/packages which need to be covered -before this lesson

+

This tutorial has the following concept dependencies:

+

Modelling : Components of +infectious disease models e.g. state variables, parameters, initial +conditions, Ordinary differential equations.

+

Epidemic theory : Transmission, Reproduction +number.

Introduction


-

Introductory text

-
+

Mathematical models are useful tools for generating future +trajectories of disease spread. Models can be used to evaluate the +implementation of non-pharmaceutical and pharmaceutical interventions +while accounting for factors such as age.

+

In this tutorial, we will use the R package {epidemics} +to generate trajectories of influenza spread. By the end of this +tutorial, you will be able to generate the trajectory below showing the +number of infectious individuals in different age categories through +time.

+
-

Inline instructor notes can help inform instructors of timing -challenges associated with the lessons. They appear in the “Instructor -View”.

-

READ THESE LINES AND ERASE:

-

The Workbench-related sections that the developer must keep are:

+

By the end of this tutorial, learners should be able to replicate the +above image on their own computers.

+
+
+
+
+

The first step is to install the R packages +epidemics.

+
+

R +

+
+if (!require("pak")) install.packages("pak")
+pak::pak("epiverse-trace/epidemics")
+
+

Model structures +

+
+

To generate predictions of infectious disease trajectories, we must +first select a mathematical model to use.

+

There is a library of models to choose from in +epidemics. Models are prefixed with epidemic and suffixed +by the infection name. In this tutorial, we will use the default +epidemic model, epidemic_default() which is described in +the next section.

+
+
+ +
+
+

Check model equations +

+
+

When using existing model structures always check the model +assumptions. Ask questions such as:

    -
  • YAML on top
  • -
  • Questions
  • -
  • Objectives
  • -
  • Keypoints
  • +
  • How is transmission modelled? e.g. direct or indirect, airborne or +vector-borne
  • +
  • What interventions are modelled?
  • +
  • What state variables are there and how do they relate to assumptions +about infection?
-

The Epiverse-TRACE sections that we encourage to keep are:

+

There can be subtle differences in model structures for the same +infection or outbreak type which can be missed without studying the +equations.

+
+
+
+
+

An epidemic model for pandemic influenza +

+

We want to generate disease trajectories of an influenza strain with +pandemic potential. We will use the default epidemic model in +epidemics, an age-structured SEIR model described by a +system of ordinary differential equations. For each age group \(i\), individuals are classed as either +susceptible \(S\), infected but not yet +infectious \(E\), infectious \(I\) or recovered \(R\).

+

The model parameters and equations are as follows :

+
    +
  • transmission rate \(\beta\),
  • +
  • contact matrix \(C\) containing the +frequency of contacts between age groups (a square \(i \times j\) matrix),
  • +
  • rate of transition from exposed to infectious \(\alpha\) (preinfectious period=\(1/\alpha\)),
  • +
  • recovery rate \(\gamma\) +(infectious period = \(1/\gamma\)).
  • +
+

\[ +\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} +\]

+

The contact matrix is a square matrix consisting of +rows/columns equal to the number age groups. Each element represents the +frequency of contacts between age groups. If we believe that +transmission of an infection is driven by contact, and that contact +rates are very different for different age groups, then specifying a +contact matrix allows us to account for age specific rates of +transmission.

+

From the model structure we see that :

    -
  • Prerequisites
  • -
  • Introduction
  • +
  • the contact matrix \(C\) allows for +heterogeneity in contacts between age groups,
  • +
  • there is no loss of immunity (there are no flows out of the +recovered state).
  • +
+

This model also has the functionality to include vaccination and +tracks the number of vaccinated individuals through time. We will cover +the use of interventions in future tutorials.

+
+
+ +
+
+

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.
-

Take a look to the Contributing.md file for more writing -guidelines.

+

To generate trajectories using our model, we need the following :

+
    +
  1. parameter values,
  2. +
  3. contact matrix,
  4. +
  5. demographic structure,
  6. +
  7. initial conditions.
  8. +
-

Section header +

Model parameters


-

Lesson content

-
+

To run our model we need to specify the model parameters:

+
    +
  • transmission rate \(\beta\),
  • +
  • rate of transition from exposed to infectious \(\alpha\) (preinfectious period=\(1/\alpha\)),
  • +
  • recovery rate \(\gamma\) +(infectious period=\(1/\gamma\)).
  • +
+

We will learn how to specify the contact matrix \(C\) in the next section.

+

We will simulate a strain of influenza with pandemic potential with +\(R_0=1.5\), a preinfectious period of +3 days and infectious period of 7 days.

+

In epidemics, we use the function +infection() to create an infection object containing the +values of, \(R_0\), the preinfectious +period (\(1/\alpha\)) and the +infectious period (\(1/\gamma\)) as +follows.

+
+

R +

+
+influenza <- infection(
+  name = "influenza",
+  r0 = 1.5,
+  preinfectious_period = 3,
+  infectious_period = 7
+)
+
+
+
+ +
+
+

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 the transmission rate, \(\beta\), as:

+

\[ \beta = R_0 \gamma.\]

+
+
+
+ +
+

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).

+
-
-

Challenge 1 : can the learner run existing -code +
+

Load contact and population data

-

Load contact and population data from socialmixr::polymod

-
+

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(
-  polymod,
+  survey = polymod,
   countries = "United Kingdom",
   age.limits = c(0, 20, 40),
   symmetric = TRUE
 )
-contact_data
+# prepare contact matrix +contact_matrix <- t(contact_data$matrix) +contact_matrix
@@ -368,136 +580,1059 @@

OUTPUT

-
Using POLYMOD social contact data. To cite this in a publication, use the 'get_citation()' function
+
                 
+contact.age.group     [,1]     [,2]     [,3]
+          [0,20)  7.883663 2.794154 1.565665
+          [20,40) 3.120220 4.854839 2.624868
+          40+     3.063895 4.599893 5.005571
+
+

+

+
+
+

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 in the correct format to be used in epidemics.

+
+
+ +
+
+

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 +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).

+
+
+
+
+

Generating trajectories +

+
+

We have prepared our parameter values, contact matrix and demography +vector. Now we must set the initial conditions, prepare the population +and run the model.

+
+

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_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_conditions_free <- c(
+  S = 1, E = 0, I = 0, R = 0, V = 0
+)
+
+

We combine the three initial conditions vectors into one matrix,

+
+

R +

+
+# build for all age groups
+initial_conditions <- rbind(
+  initial_conditions_inf,
+  initial_conditions_free,
+  initial_conditions_free
+)
+rownames(initial_conditions) <- rownames(contact_matrix)
+initial_conditions

OUTPUT

-
Removing participants that have contacts without age information. To change this behaviour, set the 'missing.contact.age' option
+
               S E     I R V
+[0,20)  0.999999 0 1e-06 0 0
+[20,40) 1.000000 0 0e+00 0 0
+40+     1.000000 0 0e+00 0 0
+
+
+
+

Running the model +

+

To run the model we need the following inputs:

+
    +
  • an infection object,
  • +
  • a population object,
  • +
  • an optional number of time steps.
  • +
+

We have already created our infection object influenza. +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_vector <- contact_data$demography$population
+names(demography_vector) <- rownames(contact_matrix)
+demography_vector

OUTPUT

-
$matrix
-      contact.age.group
-         [0,20)  [20,40)      40+
-  [1,] 7.883663 3.120220 3.063895
-  [2,] 2.794154 4.854839 4.599893
-  [3,] 1.565665 2.624868 5.005571
-
-$demography
-   age.group population proportion year
-1:    [0,20)   14799290  0.2454816 2005
-2:   [20,40)   16526302  0.2741283 2005
-3:       40+   28961159  0.4803901 2005
-
-$participants
-   age.group participants proportion
-1:    [0,20)          404  0.3996044
-2:   [20,40)          248  0.2453017
-3:       40+          359  0.3550940
+
  [0,20)  [20,40)      40+ 
+14799290 16526302 28961159 
+

To create our population object, we call the function +population() specifying a name, the contact matrix, the +demography vector and the initial conditions.

+
+

R +

+
+uk_population <- population(
+  name = "UK",
+  contact_matrix = contact_matrix,
+  demography_vector = demography_vector,
+  initial_conditions = initial_conditions
+)
+

No we are ready to run our model. We will specify +time_end=600 to run the model for 600 days.

+
+

R +

+
+output <- epidemic_default_cpp(
+  population = uk_population,
+  infection = influenza,
+  time_end = 600
+)
+head(output)
+
+
+

OUTPUT +

+
   time demography_group compartment    value
+1:    0           [0,20) susceptible 14799275
+2:    0          [20,40) susceptible 16526302
+3:    0              40+ susceptible 28961159
+4:    0           [0,20)     exposed        0
+5:    0          [20,40)     exposed        0
+6:    0              40+     exposed        0
+
+

Our model output consists of the number of individuals in each +compartment in each age group through time. We can visualise the +infectious individuals only (those in the \(I\) class) through time.

+
+

R +

+
+ggplot(output[compartment == "infectious", ]) +
+  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,
+    name = "Infectious indivduals"
+  ) +
+  labs(
+    x = "Model time (days)"
+  ) +
+  theme_classic() +
+  theme(
+    legend.position = "top"
+  ) +
+  theme_grey(
+    base_size = 15
+  )
+
+
+
+ +
+
+

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 and +maximum number of time steps is days, the default increment is 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, 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
  2. +
+
+

R +

+
+R0_vec <- rnorm(100, 1.5, 0.05)
+
+
    +
  1. Run the model 100 times with \(R_0\) equal to a different sample each +time
  2. +
+
+

R +

+
+output_samples <- Map(
+ R0_vec,
+  seq_along(R0_vec),
+  f = function(x, i) {
+  # create infection object for R0 value
+    influenza <- infection(
+      name = "influenza",
+      r0 = x,
+      preinfectious_period = 3,
+      infectious_period = 7
+    )
+
+    # run an epidemic model using `epidemic()`
+    output <- epidemic_default_cpp(
+      population = uk_population,
+      infection = influenza,
+      time_end = 600, increment = 1.0
+    )
+
+    # extract infectious individuals 
+    output <- output[compartment == "infectious"]
+
+    # assign scenario number
+    output[, c("scenario", "R") := list(i, x)]
+
+    output
+  }
+)
+
+# combine to prepare for plotting
+output_samples <- bind_rows(output_samples)
+
    +
  1. Calculate the mean and 95% quantiles of number of infectious +individuals across each model simulation and visualise output
  2. +
+
+

R +

+
+ggplot(output_samples ,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)
+  ) +
+  theme_grey(
+    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.

-

Section header +

Summary


-

Lesson content

-
+

In this tutorial, we have learnt how to generate disease trajectories +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.

+
- +
-
-

Explainer +
+

Keypoints

-

Add additional maths (or epi) content for novice learners

+
    +
  • Disease trajectories can be generated using the R package +epidemics +
  • +
  • Contact matrices can be estimated from different sources
  • +
  • Include uncertainty in model trajectories
  • +
+
+
+

+ +

Content from Choosing an appropriate model

+
+

Last updated on 2023-10-31 | + + Edit this page

+

Estimated time 30 minutes

+
+ +
+
+

Overview

+
+
+
+
+

Questions

+
    +
  • How do I choose a model for my task?
  • +
+
+
+
+
+
+
+

Objectives

+
    +
  • Learn how to access the model library in epidemics +
  • +
  • Understand the model requirements for a question
  • +
+
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
    +
  • Complete tutorial ‘Simulating transmission’
  • +
+
+
+
+

Introduction +

+
+

Using mathematical models in outbreak analysis does not necessarily +require developing a new model. There are existing 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 generate predictions for a given scenario.

+
+
+ +
+
+

The focus of this tutorial is understanding existing models to decide +if they are appropriate for a defined question.

+
+
+
+
+
+

Choosing a model +

+

When deciding whether an existing model can be used, we must consider +:

+
    +
  • 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.

+
    +
  • Do we need a deterministic or 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.

+
    +
  • 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.

+
    +
  • 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 will discuss interventions in detail in the +next tutorial.

+
+
+

Available models +

+

The R package epidemics contains functions to run +existing models. For details on the models that are available, see the +package vignettes. +To learn how to run the models in R, read the documentation using +?epidemics::epidemic_ebola. Remember to use the ‘Check +model equation’ questions to help your understanding of an existing +model.

+
+
+ +
+
+

Check model equations +

+
+
    +
  • How is transmission modelled? e.g. direct or indirect, airborne or +vector-borne
  • +
  • What interventions are modelled?
  • +
  • What state variables are there and how do they relate to assumptions +about infection?
  • +
+
-
+

Challenge +

+
+
-
-

Challenge 2 : edit code/answer a question +
+

What model?

-

Load contact and population data for Poland from socialmixr::polymod -using the following age bins:

+

You have been asked to explore the variation in numbers of infected +individuals in the early stages of an Ebola outbreak.

+

Which of the following models would be an appropriate choice for this +task:

    -
  • [0,15)
  • -
  • [15, 50)
  • -
  • 50 +
  • +
  • epidemic_default

  • +
  • epidemic_ebola

-
+
- -
+
-
-

R +

Consider the following questions:

+
+
+ +
+
+

Checklist

-
-polymod <- socialmixr::polymod
-contact_data <- socialmixr::contact_matrix(
-  polymod,
-  countries = "Poland",
-  age.limits = c(0, 15, 50),
-  symmetric = TRUE
-)
+
+
    +
  • 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?
  • +
+
+
+
+

+
+
+
+
+
+ +
+
+
    +
  • 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 +
  • +
+
+

+epidemic_default +

+

A deterministic SEIR model with age specific direct transmission.

+

The model is capable of predicting an Ebola type outbreak, but as the +model is deterministic, we are not able to explore stochastic variation +in the early stages of the outbreak.

+
+
+

+epidemic_ebola +

+

A stochastic SEIHFR (Susceptible, Exposed, Infectious, Hospitalised, +Funeral, Removed) model that was developed specifically for infection +with Ebola.

+

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.

+
+
+
+
+
+
+
+ +
+
+

Keypoints +

+
+
    +
  • Existing models can be used for new questions
  • +
  • Check that a model has appropriate assumptions about transmission, +outbreak potential, outcomes and interventions
  • +
+
+
+
+ +

Content from Modelling interventions

+
+

Last updated on 2023-10-31 | + + Edit this page

+

Estimated time 75 minutes

+
+ +
+
+

Overview

+
+
+
+
+

Questions

+
    +
  • How do I investigate the effect of interventions on disease +trajectories?
  • +
+
+
+
+
+
+
+

Objectives

+
    +
  • Learn how to implement pharmaceutical and non-pharmaceutical +interventions
  • +
+
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
    +
  • Complete tutorial ‘Simulating transmission’
  • +
+

This tutorial has the following concept dependencies:

+

Outbreak response : Intervention +types.

+
+
+

Introduction +

+
+

Mathematical models can be used to generate predictions for the +implementation of non-pharmaceutical and pharmaceutical interventions at +different stages of an outbreak. In this tutorial, we will introduce how +to include different interventions in models.

+
+
+ +
+
+

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 (NPIs) are measures put in place to +reduce transmission that do not include taking medicine or vaccines. +NPIs aim reduce contact between infectious and susceptible individuals. +For example, washing hands, wearing masks and closures of school and +workplaces.

+

In mathematical modelling, we must make assumptions about how NPIs +will affect transmission. This may include adding additional disease +states or reducing the value of relevant parameters.

+
+

Effect of school closures on COVID-19 spread +

+

We want to investigate the effect of school closures on reducing the +number of individuals infectious with COVID-19 through time. We assume +that a school closure will reduce the frequency of contacts within and +between different age groups.

+

Using an SEIR model (epidemic_default() in the R package +{epidemics}) we set \(R_0 = +2.7\), preinfectious period \(= +4\) and the infectious_period \(= +5.5\) (parameters adapted from Davies et +al. (2020)). We load a contact matrix with age bins 0-18, 18-65, 65 +years and older using socialmixr and assume that one in +every 1 million in each age group is infectious at the start of the +epidemic.

+

We will assume that school closures will reduce the contacts between +school aged children (aged 0-15) by 0.5, and will cause a small +reduction (0.01) in the contacts between adults (aged 15 and over).

+
+
+ +
+
+

Effect of interventions on contacts +

+
+

The contact matrix is scaled down by proportions for the period in +which the intervention is in place. To explain the reduction, consider a +contact matrix for two age groups with equal number of contacts:

OUTPUT

-
Using POLYMOD social contact data. To cite this in a publication, use the 'get_citation()' function
+
     [,1] [,2]
+[1,]    1    1
+[2,]    1    1
+

If the reduction is 50% in group 1 and 10% in group 2, the contact +matrix during the intervention will be:

OUTPUT

-
Removing participants that have contacts without age information. To change this behaviour, set the 'missing.contact.age' option
+
     [,1] [,2]
+[1,] 0.25 0.45
+[2,] 0.45 0.81
-
+

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\)).

+
+
+
+

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

-contact_data
+rownames(contact_matrix)

OUTPUT

-
$matrix
-      contact.age.group
-          [0,15)   [15,50)      50+
-  [1,] 8.4882943  5.047958 1.765826
-  [2,] 1.5998125 14.049041 3.624419
-  [3,] 0.9468591  6.132289 4.314050
-
-$demography
-   age.group population proportion year
-1:    [0,15)    6372248  0.1661054 2005
-2:   [15,50)   20106632  0.5241197 2005
-3:       50+   11883794  0.3097749 2005
-
-$participants
-   age.group participants proportion
-1:    [0,15)          299  0.2960396
-2:   [15,50)          469  0.4643564
-3:       50+          242  0.2396040
+
[1] "[0,15)"  "[15,65)" "65+"    
+
+

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 +

+
+close_schools <- intervention(
+  name = "School closure",
+  type = "contacts",
+  time_begin = 50,
+  time_end = 50 + 100,
+  reduction = matrix(c(0.5, 0.01, 0.01))
+)
+
+

To run the model with an intervention we set +intervention = list(contacts = close_schools) as +follows:

+
+

R +

+
+output_school <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  intervention = list(contacts = close_schools),
+  time_end = 300, increment = 1.0
+)
+
+

We see that with the intervention (solid line) in place, the +infection still spreads through the population, though the epidemic peak +is smaller than the baseline with no intervention in place (dashed +line).

+
+
+
+

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 transmission rate +\(\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)

+

We create an intervention object with type = rate and +reduction = 0.161. Using parameters adapted from Li et al. 2020 +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 +

+
+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 <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  intervention = list(beta = mask_mandate),
+  time_end = 300, increment = 1.0
+)
+
+
+
+

Pharmaceutical interventions +

+
+

Models can be used to investigate the effect of pharmaceutical +interventions, such as vaccination. In this case, it is useful to add +another disease state to track the number of vaccinated individuals +through time. The diagram below shows an SEIRV model where susceptible +individuals are vaccinated and then move to the \(V\) class.

+

The equations describing this model are as follows:

+

\[ +\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\)). The SEIR components of these +equations are described in the tutorial Simulating transmission.

+

To explore the effect of vaccination we need to create a vaccination +object. As vaccination is age group specific, we must pass an age groups +specific vaccination rate \(\nu\) and +age group specific start and end times of the vaccination program. Here +we will assume all age groups are vaccinated at the same rate and that +the vaccination program starts on day 40 and is in place for 150 +days.

+
+

R +

+
+# 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 <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  vaccination = vaccinate,
+  time_end = 300, increment = 1.0
+)
+

Here we see that the total number of infectious individuals when +vaccination is in place is much lower compared to school closures and +mask wearing interventions.

+

Summary +

+
+

Modelling interventions requires assumptions of how interventions +affect model parameters such as contact matrices or parameter values. +Next we want quantify the effect of an interventions. In the next +tutorial, we will learn how to compare intervention scenarios against +each other.

+
+
+
+
+

Keypoints +

+
+
    +
  • Different types of intervention can be implemented using +mathematical modelling
  • +
+
+ +

Content from Comparing public health outcomes of interventions

+
+

Last updated on 2023-10-31 | + + Edit this page

+

Estimated time 75 minutes

+
+ +
+
+

Overview

+
+
+
+
+

Questions

+
    +
  • How can I quantify the effect of an intervention?
  • +
+
+
+
+
+
+
+

Objectives

+
    +
  • Understand how to compare intervention scenarios
  • +
+
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
    +
  • Complete tutorials ‘Simulating transmission’ and ‘Modelling +interventions’
  • +
+

This tutorial has the following concept dependencies:

+

Outbreak response : Intervention +types.

+
+
+
+

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.
  • +
+
+
+ +
+
+

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. 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.

+

See ?epidemics::epidemic_vacamole for detail on how to +run the model.

+

Comparing scenarios +

+
+

Coming soon

+

Challenge +

+
+

Coming soon

+ + + + + + + + + @@ -541,8 +1677,8 @@

KeypointsCC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -564,7 +1700,7 @@

Keypoints +Epiverse-TRACE: Comparing public health outcomes of interventions +
+ Epiverse-TRACE +
+ +
+
+ + + + + +
+
+

Comparing public health outcomes of interventions

+

Last updated on 2023-10-31 | + + Edit this page

+ + + +

Estimated time 75 minutes

+ +
+ +
+ + + +
+

Overview

+
+
+
+
+

Questions

+
  • How can I quantify the effect of an intervention?
  • +
+
+
+
+
+
+

Objectives

+
  • Understand how to compare intervention scenarios
  • +
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
  • Complete tutorials ‘Simulating transmission’ and ‘Modelling +interventions’
  • +

This tutorial has the following concept dependencies:

+

Outbreak response : Intervention +types.

+
+
+
+

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.
  • +
+
+ +
+
+

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. 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.

+

See ?epidemics::epidemic_vacamole for detail on how to +run the model.

+

Comparing scenarios +

+

Coming soon

+

Challenge +

+

Coming soon

+ + + + + + + + + +
+
+ +
+
+

Keypoints +

+
+
  • The counter factual scenario must be defined to make +comparisons
  • +
+
+
+ +
+
+ + +
+
+ + + diff --git a/instructor/images.html b/instructor/images.html index 1d8eab18..f6b809db 100644 --- a/instructor/images.html +++ b/instructor/images.html @@ -179,7 +179,43 @@

+ + + + + +
+ + +
+ + +
+
+ @@ -242,8 +278,33 @@

-

Lesson title

-
+

Simulating transmission

+
+

Figure 1

+

+

Figure 2

+

+

Figure 3

+

+

Figure 4

+

Choosing an appropriate model

+
+

Figure 1

+

+

Figure 2

+

Modelling interventions

+
+

Figure 1

+

+

Figure 2

+

+

Figure 3

+

+

Figure 4

+

Comparing public health outcomes of interventions

+
+

Figure 1

+

@@ -268,8 +329,8 @@

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -291,7 +352,7 @@

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/instructor/images.html", "identifier": "https://epiverse-trace.github.io/tutorials/instructor/images.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/instructor/index.html b/instructor/index.html index 10ccc85b..3fe9b8a7 100644 --- a/instructor/index.html +++ b/instructor/index.html @@ -150,7 +150,34 @@

+ + + + + +
+ @@ -198,11 +225,11 @@

Summary and Schedule

@@ -220,13 +247,43 @@

Duration: 00h 00m - 1. Lesson title + 1. Simulating transmission + + +How do I generate predictions of disease trajectories?
What inputs +are needed for a model simulation? + + +Duration: 01h 15m + + + 2. Choosing an appropriate model + + +How do I choose a model for my task? + + +Duration: 01h 45m + + + 3. Modelling interventions + + +How do I investigate the effect of interventions on disease +trajectories? + + +Duration: 03h 00m + + + 4. Comparing public health +outcomes of interventions -What questions will this lesson cover? +How can I quantify the effect of an intervention? -Duration: 00h 15m +Duration: 04h 15m Finish @@ -258,11 +315,11 @@

any links that you are not going to use. -->

@@ -284,8 +341,8 @@

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -306,7 +363,7 @@

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/instructor/index.html", "identifier": "https://epiverse-trace.github.io/tutorials/instructor/index.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/instructor/instructor-notes.html b/instructor/instructor-notes.html index 51b73b3d..23cab7cb 100644 --- a/instructor/instructor-notes.html +++ b/instructor/instructor-notes.html @@ -179,7 +179,43 @@

+ + + + + +
+ + +
+ + +
+
+ @@ -250,29 +286,40 @@

Instructor Notes

--> -

Lesson title

+

Simulating transmission

+
+

+Instructor Note +

+

By the end of this tutorial, learners should be able to replicate the +above image on their own computers.

+
+

Choosing an appropriate model

+
+

+Instructor Note +

+

The focus of this tutorial is understanding existing models to decide +if they are appropriate for a defined question.

+
+

Modelling interventions

+
+

+Instructor Note +

+

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.

+
+

Comparing public health outcomes of interventions


-

-Instructor Note +

+Instructor Note

-

Inline instructor notes can help inform instructors of timing -challenges associated with the lessons. They appear in the “Instructor -View”.

-

READ THESE LINES AND ERASE:

-

The Workbench-related sections that the developer must keep are:

-
    -
  • YAML on top
  • -
  • Questions
  • -
  • Objectives
  • -
  • Keypoints
  • -
-

The Epiverse-TRACE sections that we encourage to keep are:

-
    -
  • Prerequisites
  • -
  • Introduction
  • -
-

Take a look to the Contributing.md file for more writing -guidelines.

+

In this tutorial we introduce the concept of the counter factual and +how to compare scenarios (counter factual versus intervention) against +each other.



@@ -299,8 +346,8 @@

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -322,7 +369,7 @@

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/instructor/instructor-notes.html", "identifier": "https://epiverse-trace.github.io/tutorials/instructor/instructor-notes.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/instructor/key-points.html b/instructor/key-points.html index c2ef41e7..1e096517 100644 --- a/instructor/key-points.html +++ b/instructor/key-points.html @@ -179,7 +179,43 @@

+ + + + + +
+ + +
+ + +
+
+ @@ -242,10 +278,30 @@

-

Lesson title

+

Simulating transmission

+
+
    +
  • Disease trajectories can be generated using the R package +epidemics +
  • +
  • Contact matrices can be estimated from different sources
  • +
  • Include uncertainty in model trajectories
  • +

Choosing an appropriate model

+
+
    +
  • Existing models can be used for new questions
  • +
  • Check that a model has appropriate assumptions about transmission, +outbreak potential, outcomes and interventions
  • +

Modelling interventions

+
+
    +
  • Different types of intervention can be implemented using +mathematical modelling
  • +

Comparing public health outcomes of interventions


    -
  • Summarise the key points of the lesson using bullet points
  • +
  • The counter factual scenario must be defined to make +comparisons
@@ -271,8 +327,8 @@

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -294,7 +350,7 @@

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/instructor/key-points.html", "identifier": "https://epiverse-trace.github.io/tutorials/instructor/key-points.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/instructor/model-choices.html b/instructor/model-choices.html new file mode 100644 index 00000000..ee75e431 --- /dev/null +++ b/instructor/model-choices.html @@ -0,0 +1,575 @@ + +Epiverse-TRACE: Choosing an appropriate model +
+ Epiverse-TRACE +
+ +
+
+ + + + + +
+
+

Choosing an appropriate model

+

Last updated on 2023-10-31 | + + Edit this page

+ + + +

Estimated time 30 minutes

+ +
+ +
+ + + +
+

Overview

+
+
+
+
+

Questions

+
  • How do I choose a model for my task?
  • +
+
+
+
+
+
+

Objectives

+
  • Learn how to access the model library in epidemics +
  • +
  • Understand the model requirements for a question
  • +
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
  • Complete tutorial ‘Simulating transmission’
  • +
+
+
+

Introduction +

+

Using mathematical models in outbreak analysis does not necessarily +require developing a new model. There are existing 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 generate predictions for a given scenario.

+
+
+ +
+
+

The focus of this tutorial is understanding existing models to decide +if they are appropriate for a defined question.

+
+
+
+
+
+

Choosing a model

+

When deciding whether an existing model can be used, we must consider +:

+
  • 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.

+
  • Do we need a deterministic or 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.

+
  • 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.

+
  • 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 will discuss interventions in detail in the +next tutorial.

+
+
+

Available models

+

The R package epidemics contains functions to run +existing models. For details on the models that are available, see the +package vignettes. +To learn how to run the models in R, read the documentation using +?epidemics::epidemic_ebola. Remember to use the ‘Check +model equation’ questions to help your understanding of an existing +model.

+
+
+ +
+
+

Check model equations +

+
+
  • How is transmission modelled? e.g. direct or indirect, airborne or +vector-borne
  • +
  • What interventions are modelled?
  • +
  • What state variables are there and how do they relate to assumptions +about infection?
  • +
+
+
+
+

Challenge +

+
+
+ +
+
+

What model? +

+
+

You have been asked to explore the variation in numbers of infected +individuals in the early stages of an Ebola outbreak.

+

Which of the following models would be an appropriate choice for this +task:

+
  • epidemic_default

  • +
  • epidemic_ebola

  • +
+
+
+
+
+ +
+
+

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?
  • +
+
+
+
+
+
+
+
+
+ +
+
+
  • 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 +
  • +
+

epidemic_default

+

A deterministic SEIR model with age specific direct transmission.

+

The model is capable of predicting an Ebola type outbreak, but as the +model is deterministic, we are not able to explore stochastic variation +in the early stages of the outbreak.

+
+
+

epidemic_ebola

+

A stochastic SEIHFR (Susceptible, Exposed, Infectious, Hospitalised, +Funeral, Removed) model that was developed specifically for infection +with Ebola.

+

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.

+
+
+
+
+
+
+
+ +
+
+

Keypoints +

+
+
  • Existing models can be used for new questions
  • +
  • Check that a model has appropriate assumptions about transmission, +outbreak potential, outcomes and interventions
  • +
+
+
+ +
+
+ + +
+
+ + + diff --git a/instructor/modelling-interventions.html b/instructor/modelling-interventions.html new file mode 100644 index 00000000..a1de24cd --- /dev/null +++ b/instructor/modelling-interventions.html @@ -0,0 +1,659 @@ + +Epiverse-TRACE: Modelling interventions +
+ Epiverse-TRACE +
+ +
+
+ + + + + +
+
+

Modelling interventions

+

Last updated on 2023-10-31 | + + Edit this page

+ + + +

Estimated time 75 minutes

+ +
+ +
+ + + +
+

Overview

+
+
+
+
+

Questions

+
  • How do I investigate the effect of interventions on disease +trajectories?
  • +
+
+
+
+
+
+

Objectives

+
  • Learn how to implement pharmaceutical and non-pharmaceutical +interventions
  • +
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
  • Complete tutorial ‘Simulating transmission’
  • +

This tutorial has the following concept dependencies:

+

Outbreak response : Intervention +types.

+
+
+
+

Introduction +

+

Mathematical models can be used to generate predictions for the +implementation of non-pharmaceutical and pharmaceutical interventions at +different stages of an outbreak. In this tutorial, we will introduce how +to include different interventions in models.

+
+
+ +
+
+

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 (NPIs) are measures put in place to +reduce transmission that do not include taking medicine or vaccines. +NPIs aim reduce contact between infectious and susceptible individuals. +For example, washing hands, wearing masks and closures of school and +workplaces.

+

In mathematical modelling, we must make assumptions about how NPIs +will affect transmission. This may include adding additional disease +states or reducing the value of relevant parameters.

+
+

Effect of school closures on COVID-19 spread

+

We want to investigate the effect of school closures on reducing the +number of individuals infectious with COVID-19 through time. We assume +that a school closure will reduce the frequency of contacts within and +between different age groups.

+

Using an SEIR model (epidemic_default() in the R package +{epidemics}) we set \(R_0 = +2.7\), preinfectious period \(= +4\) and the infectious_period \(= +5.5\) (parameters adapted from Davies et +al. (2020)). We load a contact matrix with age bins 0-18, 18-65, 65 +years and older using socialmixr and assume that one in +every 1 million in each age group is infectious at the start of the +epidemic.

+

We will assume that school closures will reduce the contacts between +school aged children (aged 0-15) by 0.5, and will cause a small +reduction (0.01) in the contacts between adults (aged 15 and over).

+
+
+ +
+
+

Effect of interventions on contacts +

+
+

The contact matrix is scaled down by proportions for the period in +which the intervention is in place. To explain the reduction, consider a +contact matrix for two age groups with equal number of contacts:

+
+

OUTPUT +

+
     [,1] [,2]
+[1,]    1    1
+[2,]    1    1
+
+

If the reduction is 50% in group 1 and 10% in group 2, the contact +matrix during the intervention will be:

+
+

OUTPUT +

+
     [,1] [,2]
+[1,] 0.25 0.45
+[2,] 0.45 0.81
+
+

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\)).

+
+
+
+

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)
+
+
+

OUTPUT +

+
[1] "[0,15)"  "[15,65)" "65+"    
+
+

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 +

+
+close_schools <- intervention(
+  name = "School closure",
+  type = "contacts",
+  time_begin = 50,
+  time_end = 50 + 100,
+  reduction = matrix(c(0.5, 0.01, 0.01))
+)
+
+

To run the model with an intervention we set +intervention = list(contacts = close_schools) as +follows:

+
+

R +

+
+output_school <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  intervention = list(contacts = close_schools),
+  time_end = 300, increment = 1.0
+)
+
+

We see that with the intervention (solid line) in place, the +infection still spreads through the population, though the epidemic peak +is smaller than the baseline with no intervention in place (dashed +line).

+
+
+

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 transmission rate +\(\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)

+

We create an intervention object with type = rate and +reduction = 0.161. Using parameters adapted from Li et al. 2020 +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 +

+
+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 <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  intervention = list(beta = mask_mandate),
+  time_end = 300, increment = 1.0
+)
+
+
+

Pharmaceutical interventions +

+

Models can be used to investigate the effect of pharmaceutical +interventions, such as vaccination. In this case, it is useful to add +another disease state to track the number of vaccinated individuals +through time. The diagram below shows an SEIRV model where susceptible +individuals are vaccinated and then move to the \(V\) class.

+

The equations describing this model are as follows:

+

\[ +\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\)). The SEIR components of these +equations are described in the tutorial Simulating transmission.

+

To explore the effect of vaccination we need to create a vaccination +object. As vaccination is age group specific, we must pass an age groups +specific vaccination rate \(\nu\) and +age group specific start and end times of the vaccination program. Here +we will assume all age groups are vaccinated at the same rate and that +the vaccination program starts on day 40 and is in place for 150 +days.

+
+

R +

+
+# 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 <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  vaccination = vaccinate,
+  time_end = 300, increment = 1.0
+)
+
+

Here we see that the total number of infectious individuals when +vaccination is in place is much lower compared to school closures and +mask wearing interventions.

+

Summary +

+

Modelling interventions requires assumptions of how interventions +affect model parameters such as contact matrices or parameter values. +Next we want quantify the effect of an interventions. In the next +tutorial, we will learn how to compare intervention scenarios against +each other.

+
+
+ +
+
+

Keypoints +

+
+
  • Different types of intervention can be implemented using +mathematical modelling
  • +
+
+
+ +
+
+ + +
+
+ + + diff --git a/instructor/profiles.html b/instructor/profiles.html index 5f36aa69..b6cd879b 100644 --- a/instructor/profiles.html +++ b/instructor/profiles.html @@ -146,7 +146,34 @@

+ + + + + +
+ @@ -225,8 +252,8 @@

Learner Profiles

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -247,7 +274,7 @@

Learner Profiles

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/instructor/profiles.html", "identifier": "https://epiverse-trace.github.io/tutorials/instructor/profiles.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/instructor/reference.html b/instructor/reference.html index bb8ab98b..310d537d 100644 --- a/instructor/reference.html +++ b/instructor/reference.html @@ -1,5 +1,5 @@ -Epiverse-TRACE: Reference +
+ Epiverse-TRACE +
+ +
+
+ + + + + +
+
+

Simulating transmission

+

Last updated on 2023-10-31 | + + Edit this page

+ + + +

Estimated time 75 minutes

+ +
+ +
+ + + +
+

Overview

+
+
+
+
+

Questions

+
  • How do I generate predictions of disease trajectories?
  • +
  • What inputs are needed for a model simulation?
  • +
+
+
+
+
+
+

Objectives

+

Using the R package epidemics, learn how to:

+
  • load an existing model structure,
  • +
  • load an existing social contact matrix,
  • +
  • run a model simulation.
  • +
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+

This tutorial has the following concept dependencies:

+

Modelling : Components of +infectious disease models e.g. state variables, parameters, initial +conditions, Ordinary differential equations.

+

Epidemic theory : Transmission, Reproduction +number.

+
+
+
+

Introduction +

+

Mathematical models are useful tools for generating future +trajectories of disease spread. Models can be used to evaluate the +implementation of non-pharmaceutical and pharmaceutical interventions +while accounting for factors such as age.

+

In this tutorial, we will use the R package {epidemics} +to generate trajectories of influenza spread. By the end of this +tutorial, you will be able to generate the trajectory below showing the +number of infectious individuals in different age categories through +time.

+
+
+ +
+
+

By the end of this tutorial, learners should be able to replicate the +above image on their own computers.

+
+
+
+
+

The first step is to install the R packages +epidemics.

+
+

R +

+
+if (!require("pak")) install.packages("pak")
+pak::pak("epiverse-trace/epidemics")
+
+

Model structures +

+

To generate predictions of infectious disease trajectories, we must +first select a mathematical model to use.

+

There is a library of models to choose from in +epidemics. Models are prefixed with epidemic and suffixed +by the infection name. In this tutorial, we will use the default +epidemic model, epidemic_default() which is described in +the next section.

+
+
+ +
+
+

Check model equations +

+
+

When using existing model structures always check the model +assumptions. Ask questions such as:

+
  • How is transmission modelled? e.g. direct or indirect, airborne or +vector-borne
  • +
  • What interventions are modelled?
  • +
  • What state variables are there and how do they relate to assumptions +about infection?
  • +

There can be subtle differences in model structures for the same +infection or outbreak type which can be missed without studying the +equations.

+
+
+
+
+

An epidemic model for pandemic influenza

+

We want to generate disease trajectories of an influenza strain with +pandemic potential. We will use the default epidemic model in +epidemics, an age-structured SEIR model described by a +system of ordinary differential equations. For each age group \(i\), individuals are classed as either +susceptible \(S\), infected but not yet +infectious \(E\), infectious \(I\) or recovered \(R\).

+

The model parameters and equations are as follows :

+
  • transmission rate \(\beta\),
  • +
  • contact matrix \(C\) containing the +frequency of contacts between age groups (a square \(i \times j\) matrix),
  • +
  • rate of transition from exposed to infectious \(\alpha\) (preinfectious period=\(1/\alpha\)),
  • +
  • recovery rate \(\gamma\) +(infectious period = \(1/\gamma\)).
  • +

\[ +\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} +\]

+

The contact matrix is a square matrix consisting of +rows/columns equal to the number age groups. Each element represents the +frequency of contacts between age groups. If we believe that +transmission of an infection is driven by contact, and that contact +rates are very different for different age groups, then specifying a +contact matrix allows us to account for age specific rates of +transmission.

+

From the model structure we see that :

+
  • the contact matrix \(C\) allows for +heterogeneity in contacts between age groups,
  • +
  • there is no loss of immunity (there are no flows out of the +recovered state).
  • +

This model also has the functionality to include vaccination and +tracks the number of vaccinated individuals through time. We will cover +the use of interventions in future tutorials.

+
+
+ +
+
+

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 need the following :

+
  1. parameter values,
  2. +
  3. contact matrix,
  4. +
  5. demographic structure,
  6. +
  7. initial conditions.
  8. +
+

Model parameters +

+

To run our model we need to specify the model parameters:

+
  • transmission rate \(\beta\),
  • +
  • rate of transition from exposed to infectious \(\alpha\) (preinfectious period=\(1/\alpha\)),
  • +
  • recovery rate \(\gamma\) +(infectious period=\(1/\gamma\)).
  • +

We will learn how to specify the contact matrix \(C\) in the next section.

+

We will simulate a strain of influenza with pandemic potential with +\(R_0=1.5\), a preinfectious period of +3 days and infectious period of 7 days.

+

In epidemics, we use the function +infection() to create an infection object containing the +values of, \(R_0\), the preinfectious +period (\(1/\alpha\)) and the +infectious period (\(1/\gamma\)) as +follows.

+
+

R +

+
+influenza <- infection(
+  name = "influenza",
+  r0 = 1.5,
+  preinfectious_period = 3,
+  infectious_period = 7
+)
+
+
+
+ +
+
+

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 the transmission rate, \(\beta\), as:

+

\[ \beta = R_0 \gamma.\]

+
+
+
+ +
+

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).

+
+
+ +
+
+

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
+
+
+
+
+
+
+ +
+
+
+

OUTPUT +

+
                 
+contact.age.group     [,1]     [,2]     [,3]
+          [0,20)  7.883663 2.794154 1.565665
+          [20,40) 3.120220 4.854839 2.624868
+          40+     3.063895 4.599893 5.005571
+
+
+
+
+
+

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 in the correct format to be used in epidemics.

+
+
+ +
+
+

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 +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).

+
+
+
+
+

Generating trajectories +

+

We have prepared our parameter values, contact matrix and demography +vector. Now we must set the initial conditions, prepare the population +and run the model.

+
+

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_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_conditions_free <- c(
+  S = 1, E = 0, I = 0, R = 0, V = 0
+)
+
+

We combine the three initial conditions vectors into one matrix,

+
+

R +

+
+# build for all age groups
+initial_conditions <- rbind(
+  initial_conditions_inf,
+  initial_conditions_free,
+  initial_conditions_free
+)
+rownames(initial_conditions) <- rownames(contact_matrix)
+initial_conditions
+
+
+

OUTPUT +

+
               S E     I R V
+[0,20)  0.999999 0 1e-06 0 0
+[20,40) 1.000000 0 0e+00 0 0
+40+     1.000000 0 0e+00 0 0
+
+
+
+

Running the model

+

To run the model we need the following inputs:

+
  • an infection object,
  • +
  • a population object,
  • +
  • an optional number of time steps.
  • +

We have already created our infection object influenza. +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_vector <- contact_data$demography$population
+names(demography_vector) <- rownames(contact_matrix)
+demography_vector
+
+
+

OUTPUT +

+
  [0,20)  [20,40)      40+ 
+14799290 16526302 28961159 
+
+

To create our population object, we call the function +population() specifying a name, the contact matrix, the +demography vector and the initial conditions.

+
+

R +

+
+uk_population <- population(
+  name = "UK",
+  contact_matrix = contact_matrix,
+  demography_vector = demography_vector,
+  initial_conditions = initial_conditions
+)
+
+

No we are ready to run our model. We will specify +time_end=600 to run the model for 600 days.

+
+

R +

+
+output <- epidemic_default_cpp(
+  population = uk_population,
+  infection = influenza,
+  time_end = 600
+)
+head(output)
+
+
+

OUTPUT +

+
   time demography_group compartment    value
+1:    0           [0,20) susceptible 14799275
+2:    0          [20,40) susceptible 16526302
+3:    0              40+ susceptible 28961159
+4:    0           [0,20)     exposed        0
+5:    0          [20,40)     exposed        0
+6:    0              40+     exposed        0
+
+

Our model output consists of the number of individuals in each +compartment in each age group through time. We can visualise the +infectious individuals only (those in the \(I\) class) through time.

+
+

R +

+
+ggplot(output[compartment == "infectious", ]) +
+  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,
+    name = "Infectious indivduals"
+  ) +
+  labs(
+    x = "Model time (days)"
+  ) +
+  theme_classic() +
+  theme(
+    legend.position = "top"
+  ) +
+  theme_grey(
+    base_size = 15
+  )
+
+
+
+ +
+
+

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 and +maximum number of time steps is days, the default increment is 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, 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
  2. +
+

R +

+
+R0_vec <- rnorm(100, 1.5, 0.05)
+
+
  1. Run the model 100 times with \(R_0\) equal to a different sample each +time
  2. +
+

R +

+
+output_samples <- Map(
+ R0_vec,
+  seq_along(R0_vec),
+  f = function(x, i) {
+  # create infection object for R0 value
+    influenza <- infection(
+      name = "influenza",
+      r0 = x,
+      preinfectious_period = 3,
+      infectious_period = 7
+    )
+
+    # run an epidemic model using `epidemic()`
+    output <- epidemic_default_cpp(
+      population = uk_population,
+      infection = influenza,
+      time_end = 600, increment = 1.0
+    )
+
+    # extract infectious individuals 
+    output <- output[compartment == "infectious"]
+
+    # assign scenario number
+    output[, c("scenario", "R") := list(i, x)]
+
+    output
+  }
+)
+
+# combine to prepare for plotting
+output_samples <- bind_rows(output_samples)
+
+
  1. Calculate the mean and 95% quantiles of number of infectious +individuals across each model simulation and visualise output
  2. +
+

R +

+
+ggplot(output_samples ,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)
+  ) +
+  theme_grey(
+    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.

+
+

Summary +

+

In this tutorial, we have learnt how to generate disease trajectories +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 +
  • +
  • Contact matrices can be estimated from different sources
  • +
  • Include uncertainty in model trajectories
  • +
+
+
+ +
+
+ + +
+
+ + + diff --git a/key-points.html b/key-points.html index de774746..3ca33466 100644 --- a/key-points.html +++ b/key-points.html @@ -93,7 +93,7 @@ More @@ -181,7 +181,43 @@

+ + + + + +
+ + +
+ + + @@ -244,10 +280,30 @@

-

Lesson title

+

Simulating transmission

+
+
    +
  • Disease trajectories can be generated using the R package +epidemics +
  • +
  • Contact matrices can be estimated from different sources
  • +
  • Include uncertainty in model trajectories
  • +

Choosing an appropriate model

+
+
    +
  • Existing models can be used for new questions
  • +
  • Check that a model has appropriate assumptions about transmission, +outbreak potential, outcomes and interventions
  • +

Modelling interventions

+
+
    +
  • Different types of intervention can be implemented using +mathematical modelling
  • +

Comparing public health outcomes of interventions


    -
  • Summarise the key points of the lesson using bullet points
  • +
  • The counter factual scenario must be defined to make +comparisons
@@ -273,8 +329,8 @@

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -296,7 +352,7 @@

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/key-points.html", "identifier": "https://epiverse-trace.github.io/tutorials/key-points.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/md5sum.txt b/md5sum.txt index bf4ca39b..f8f192bf 100644 --- a/md5sum.txt +++ b/md5sum.txt @@ -1,12 +1,15 @@ "file" "checksum" "built" "date" -"CODE_OF_CONDUCT.md" "549f00b0992a7743c2bc16ea6ce3db57" "site/built/CODE_OF_CONDUCT.md" "2023-10-26" -"LICENSE.md" "14377518ee654005a18cf28549eb30e3" "site/built/LICENSE.md" "2023-10-26" -"config.yaml" "80a78c3157b1d5386b1f3d4b31af8562" "site/built/config.yaml" "2023-10-26" -"index.md" "d45b8843b661f7f6d628b6b57447b6c5" "site/built/index.md" "2023-10-26" -"links.md" "8184cf4149eafbf03ce8da8ff0778c14" "site/built/links.md" "2023-10-26" -"episodes/template.Rmd" "92e77eb5db496386f0615931ea7ab6dc" "site/built/template.md" "2023-10-26" -"instructors/instructor-notes.md" "ca3834a1b0f9e70c4702aa7a367a6bb5" "site/built/instructor-notes.md" "2023-10-26" -"learners/reference.md" "0ef3f430a2e376da0ed761e0a6175755" "site/built/reference.md" "2023-10-26" -"learners/setup.md" "b3c6bfa13fd687f926bb1a3e772a2516" "site/built/setup.md" "2023-10-26" -"profiles/learner-profiles.md" "60b93493cf1da06dfd63255d73854461" "site/built/learner-profiles.md" "2023-10-26" -"renv/profiles/lesson-requirements/renv.lock" "041a36f31a7ff43f4ba9fdfbb679a96e" "site/built/renv.lock" "2023-10-26" +"CODE_OF_CONDUCT.md" "549f00b0992a7743c2bc16ea6ce3db57" "site/built/CODE_OF_CONDUCT.md" "2023-10-31" +"LICENSE.md" "14377518ee654005a18cf28549eb30e3" "site/built/LICENSE.md" "2023-10-31" +"config.yaml" "ba8182fefb4b3a156058872157fb2d7d" "site/built/config.yaml" "2023-10-31" +"index.md" "d45b8843b661f7f6d628b6b57447b6c5" "site/built/index.md" "2023-10-31" +"links.md" "8184cf4149eafbf03ce8da8ff0778c14" "site/built/links.md" "2023-10-31" +"episodes/simulating-transmission.Rmd" "9c915400856003c134ca46edd1c52d87" "site/built/simulating-transmission.md" "2023-10-31" +"episodes/model-choices.Rmd" "113c11e0dccc812744f685df84733fdf" "site/built/model-choices.md" "2023-10-31" +"episodes/modelling-interventions.Rmd" "01eff78117bf3f53015154ca9b961651" "site/built/modelling-interventions.md" "2023-10-31" +"episodes/compare-interventions.Rmd" "d594dc0466f735d14ccbcc7b2a9d56ef" "site/built/compare-interventions.md" "2023-10-31" +"instructors/instructor-notes.md" "ca3834a1b0f9e70c4702aa7a367a6bb5" "site/built/instructor-notes.md" "2023-10-31" +"learners/reference.md" "451e0fd931938d38cf92a313192c1cdb" "site/built/reference.md" "2023-10-31" +"learners/setup.md" "b3c6bfa13fd687f926bb1a3e772a2516" "site/built/setup.md" "2023-10-31" +"profiles/learner-profiles.md" "60b93493cf1da06dfd63255d73854461" "site/built/learner-profiles.md" "2023-10-31" +"renv/profiles/lesson-requirements/renv.lock" "da153090a3bb8fe62bcd300c69550054" "site/built/renv.lock" "2023-10-31" diff --git a/model-choices.html b/model-choices.html new file mode 100644 index 00000000..c899175c --- /dev/null +++ b/model-choices.html @@ -0,0 +1,559 @@ + +Epiverse-TRACE: Choosing an appropriate model +
+ Epiverse-TRACE +
+ +
+
+ + + + + +
+
+

Choosing an appropriate model

+

Last updated on 2023-10-31 | + + Edit this page

+ + + +
+ +
+ + + +
+

Overview

+
+
+
+
+

Questions

+
  • How do I choose a model for my task?
  • +
+
+
+
+
+
+

Objectives

+
  • Learn how to access the model library in epidemics +
  • +
  • Understand the model requirements for a question
  • +
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
  • Complete tutorial ‘Simulating transmission’
  • +
+
+
+

Introduction +

+

Using mathematical models in outbreak analysis does not necessarily +require developing a new model. There are existing 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 generate predictions for a given scenario.

+ +
+

Choosing a model

+

When deciding whether an existing model can be used, we must consider +:

+
  • 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.

+
  • Do we need a deterministic or 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.

+
  • 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.

+
  • 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 will discuss interventions in detail in the +next tutorial.

+
+
+

Available models

+

The R package epidemics contains functions to run +existing models. For details on the models that are available, see the +package vignettes. +To learn how to run the models in R, read the documentation using +?epidemics::epidemic_ebola. Remember to use the ‘Check +model equation’ questions to help your understanding of an existing +model.

+
+
+ +
+
+

Check model equations +

+
+
  • How is transmission modelled? e.g. direct or indirect, airborne or +vector-borne
  • +
  • What interventions are modelled?
  • +
  • What state variables are there and how do they relate to assumptions +about infection?
  • +
+
+
+
+

Challenge +

+
+
+ +
+
+

What model? +

+
+

You have been asked to explore the variation in numbers of infected +individuals in the early stages of an Ebola outbreak.

+

Which of the following models would be an appropriate choice for this +task:

+
  • epidemic_default

  • +
  • epidemic_ebola

  • +
+
+
+
+
+ +
+
+

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?
  • +
+
+
+
+
+
+
+
+
+ +
+
+
  • 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 +
  • +
+

epidemic_default

+

A deterministic SEIR model with age specific direct transmission.

+

The model is capable of predicting an Ebola type outbreak, but as the +model is deterministic, we are not able to explore stochastic variation +in the early stages of the outbreak.

+
+
+

epidemic_ebola

+

A stochastic SEIHFR (Susceptible, Exposed, Infectious, Hospitalised, +Funeral, Removed) model that was developed specifically for infection +with Ebola.

+

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.

+
+
+
+
+
+
+
+ +
+
+

Keypoints +

+
+
  • Existing models can be used for new questions
  • +
  • Check that a model has appropriate assumptions about transmission, +outbreak potential, outcomes and interventions
  • +
+
+
+ +
+
+ + +
+
+ + + diff --git a/modelling-interventions.html b/modelling-interventions.html new file mode 100644 index 00000000..b45c14c9 --- /dev/null +++ b/modelling-interventions.html @@ -0,0 +1,641 @@ + +Epiverse-TRACE: Modelling interventions +
+ Epiverse-TRACE +
+ +
+
+ + + + + +
+
+

Modelling interventions

+

Last updated on 2023-10-31 | + + Edit this page

+ + + +
+ +
+ + + +
+

Overview

+
+
+
+
+

Questions

+
  • How do I investigate the effect of interventions on disease +trajectories?
  • +
+
+
+
+
+
+

Objectives

+
  • Learn how to implement pharmaceutical and non-pharmaceutical +interventions
  • +
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+
  • Complete tutorial ‘Simulating transmission’
  • +

This tutorial has the following concept dependencies:

+

Outbreak response : Intervention +types.

+
+
+
+

Introduction +

+

Mathematical models can be used to generate predictions for the +implementation of non-pharmaceutical and pharmaceutical interventions at +different stages of an outbreak. In this tutorial, we will introduce how +to include different interventions in models.

+ +

Non-pharmaceutical interventions +

+

Non-pharmaceutical interventions (NPIs) are measures put in place to +reduce transmission that do not include taking medicine or vaccines. +NPIs aim reduce contact between infectious and susceptible individuals. +For example, washing hands, wearing masks and closures of school and +workplaces.

+

In mathematical modelling, we must make assumptions about how NPIs +will affect transmission. This may include adding additional disease +states or reducing the value of relevant parameters.

+
+

Effect of school closures on COVID-19 spread

+

We want to investigate the effect of school closures on reducing the +number of individuals infectious with COVID-19 through time. We assume +that a school closure will reduce the frequency of contacts within and +between different age groups.

+

Using an SEIR model (epidemic_default() in the R package +{epidemics}) we set \(R_0 = +2.7\), preinfectious period \(= +4\) and the infectious_period \(= +5.5\) (parameters adapted from Davies et +al. (2020)). We load a contact matrix with age bins 0-18, 18-65, 65 +years and older using socialmixr and assume that one in +every 1 million in each age group is infectious at the start of the +epidemic.

+

We will assume that school closures will reduce the contacts between +school aged children (aged 0-15) by 0.5, and will cause a small +reduction (0.01) in the contacts between adults (aged 15 and over).

+
+
+ +
+
+

Effect of interventions on contacts +

+
+

The contact matrix is scaled down by proportions for the period in +which the intervention is in place. To explain the reduction, consider a +contact matrix for two age groups with equal number of contacts:

+
+

OUTPUT +

+
     [,1] [,2]
+[1,]    1    1
+[2,]    1    1
+
+

If the reduction is 50% in group 1 and 10% in group 2, the contact +matrix during the intervention will be:

+
+

OUTPUT +

+
     [,1] [,2]
+[1,] 0.25 0.45
+[2,] 0.45 0.81
+
+

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\)).

+
+
+
+

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)
+
+
+

OUTPUT +

+
[1] "[0,15)"  "[15,65)" "65+"    
+
+

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 +

+
+close_schools <- intervention(
+  name = "School closure",
+  type = "contacts",
+  time_begin = 50,
+  time_end = 50 + 100,
+  reduction = matrix(c(0.5, 0.01, 0.01))
+)
+
+

To run the model with an intervention we set +intervention = list(contacts = close_schools) as +follows:

+
+

R +

+
+output_school <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  intervention = list(contacts = close_schools),
+  time_end = 300, increment = 1.0
+)
+
+

We see that with the intervention (solid line) in place, the +infection still spreads through the population, though the epidemic peak +is smaller than the baseline with no intervention in place (dashed +line).

+
+
+

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 transmission rate +\(\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)

+

We create an intervention object with type = rate and +reduction = 0.161. Using parameters adapted from Li et al. 2020 +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 +

+
+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 <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  intervention = list(beta = mask_mandate),
+  time_end = 300, increment = 1.0
+)
+
+
+

Pharmaceutical interventions +

+

Models can be used to investigate the effect of pharmaceutical +interventions, such as vaccination. In this case, it is useful to add +another disease state to track the number of vaccinated individuals +through time. The diagram below shows an SEIRV model where susceptible +individuals are vaccinated and then move to the \(V\) class.

+

The equations describing this model are as follows:

+

\[ +\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\)). The SEIR components of these +equations are described in the tutorial Simulating transmission.

+

To explore the effect of vaccination we need to create a vaccination +object. As vaccination is age group specific, we must pass an age groups +specific vaccination rate \(\nu\) and +age group specific start and end times of the vaccination program. Here +we will assume all age groups are vaccinated at the same rate and that +the vaccination program starts on day 40 and is in place for 150 +days.

+
+

R +

+
+# 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 <- epidemic_default_cpp(
+  population = uk_population,
+  infection = covid,
+  vaccination = vaccinate,
+  time_end = 300, increment = 1.0
+)
+
+

Here we see that the total number of infectious individuals when +vaccination is in place is much lower compared to school closures and +mask wearing interventions.

+

Summary +

+

Modelling interventions requires assumptions of how interventions +affect model parameters such as contact matrices or parameter values. +Next we want quantify the effect of an interventions. In the next +tutorial, we will learn how to compare intervention scenarios against +each other.

+
+
+ +
+
+

Keypoints +

+
+
  • Different types of intervention can be implemented using +mathematical modelling
  • +
+
+
+ +
+
+ + +
+
+ + + diff --git a/pkgdown.yml b/pkgdown.yml index 19650930..397e0821 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -2,5 +2,5 @@ pandoc: 2.19.2 pkgdown: 2.0.7 pkgdown_sha: ~ articles: {} -last_built: 2023-10-31T00:38Z +last_built: 2023-10-31T16:15Z diff --git a/profiles.html b/profiles.html index 04f90fe8..d419136b 100644 --- a/profiles.html +++ b/profiles.html @@ -73,7 +73,7 @@ -
@@ -147,7 +147,34 @@

+ + + + + + @@ -226,8 +253,8 @@

Learner Profiles

Materials licensed under CC-BY 4.0 by the authors

Template licensed under CC-BY 4.0 by The Carpentries

-

Built with sandpaper (0.14.0), - pegboard (0.7.1), +

Built with sandpaper (0.14.0), + pegboard (0.7.1.9000), and varnish (0.3.1).

@@ -248,7 +275,7 @@

Learner Profiles

"creativeWorkStatus": "active", "url": "https://epiverse-trace.github.io/tutorials/profiles.html", "identifier": "https://epiverse-trace.github.io/tutorials/profiles.html", - "dateCreated": "2023-10-30", + "dateCreated": "2023-10-31", "dateModified": "2023-10-31", "datePublished": "2023-10-31" } diff --git a/reference.html b/reference.html index f9e6b7f7..4afea745 100644 --- a/reference.html +++ b/reference.html @@ -1,5 +1,5 @@ -Epiverse-TRACE: Reference +
+ Epiverse-TRACE +
+ +
+
+ + + + + +
+
+

Simulating transmission

+

Last updated on 2023-10-31 | + + Edit this page

+ + + +
+ +
+ + + +
+

Overview

+
+
+
+
+

Questions

+
  • How do I generate predictions of disease trajectories?
  • +
  • What inputs are needed for a model simulation?
  • +
+
+
+
+
+
+

Objectives

+

Using the R package epidemics, learn how to:

+
  • load an existing model structure,
  • +
  • load an existing social contact matrix,
  • +
  • run a model simulation.
  • +
+
+
+
+
+
+
+ +
+
+

Prerequisites +

+
+

This tutorial has the following concept dependencies:

+

Modelling : Components of +infectious disease models e.g. state variables, parameters, initial +conditions, Ordinary differential equations.

+

Epidemic theory : Transmission, Reproduction +number.

+
+
+
+

Introduction +

+

Mathematical models are useful tools for generating future +trajectories of disease spread. Models can be used to evaluate the +implementation of non-pharmaceutical and pharmaceutical interventions +while accounting for factors such as age.

+

In this tutorial, we will use the R package {epidemics} +to generate trajectories of influenza spread. By the end of this +tutorial, you will be able to generate the trajectory below showing the +number of infectious individuals in different age categories through +time.

+

The first step is to install the R packages +epidemics.

+
+

R +

+
+if (!require("pak")) install.packages("pak")
+pak::pak("epiverse-trace/epidemics")
+
+

Model structures +

+

To generate predictions of infectious disease trajectories, we must +first select a mathematical model to use.

+

There is a library of models to choose from in +epidemics. Models are prefixed with epidemic and suffixed +by the infection name. In this tutorial, we will use the default +epidemic model, epidemic_default() which is described in +the next section.

+
+
+ +
+
+

Check model equations +

+
+

When using existing model structures always check the model +assumptions. Ask questions such as:

+
  • How is transmission modelled? e.g. direct or indirect, airborne or +vector-borne
  • +
  • What interventions are modelled?
  • +
  • What state variables are there and how do they relate to assumptions +about infection?
  • +

There can be subtle differences in model structures for the same +infection or outbreak type which can be missed without studying the +equations.

+
+
+
+
+

An epidemic model for pandemic influenza

+

We want to generate disease trajectories of an influenza strain with +pandemic potential. We will use the default epidemic model in +epidemics, an age-structured SEIR model described by a +system of ordinary differential equations. For each age group \(i\), individuals are classed as either +susceptible \(S\), infected but not yet +infectious \(E\), infectious \(I\) or recovered \(R\).

+

The model parameters and equations are as follows :

+
  • transmission rate \(\beta\),
  • +
  • contact matrix \(C\) containing the +frequency of contacts between age groups (a square \(i \times j\) matrix),
  • +
  • rate of transition from exposed to infectious \(\alpha\) (preinfectious period=\(1/\alpha\)),
  • +
  • recovery rate \(\gamma\) +(infectious period = \(1/\gamma\)).
  • +

\[ +\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} +\]

+

The contact matrix is a square matrix consisting of +rows/columns equal to the number age groups. Each element represents the +frequency of contacts between age groups. If we believe that +transmission of an infection is driven by contact, and that contact +rates are very different for different age groups, then specifying a +contact matrix allows us to account for age specific rates of +transmission.

+

From the model structure we see that :

+
  • the contact matrix \(C\) allows for +heterogeneity in contacts between age groups,
  • +
  • there is no loss of immunity (there are no flows out of the +recovered state).
  • +

This model also has the functionality to include vaccination and +tracks the number of vaccinated individuals through time. We will cover +the use of interventions in future tutorials.

+
+
+ +
+
+

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 need the following :

+
  1. parameter values,
  2. +
  3. contact matrix,
  4. +
  5. demographic structure,
  6. +
  7. initial conditions.
  8. +
+

Model parameters +

+

To run our model we need to specify the model parameters:

+
  • transmission rate \(\beta\),
  • +
  • rate of transition from exposed to infectious \(\alpha\) (preinfectious period=\(1/\alpha\)),
  • +
  • recovery rate \(\gamma\) +(infectious period=\(1/\gamma\)).
  • +

We will learn how to specify the contact matrix \(C\) in the next section.

+

We will simulate a strain of influenza with pandemic potential with +\(R_0=1.5\), a preinfectious period of +3 days and infectious period of 7 days.

+

In epidemics, we use the function +infection() to create an infection object containing the +values of, \(R_0\), the preinfectious +period (\(1/\alpha\)) and the +infectious period (\(1/\gamma\)) as +follows.

+
+

R +

+
+influenza <- infection(
+  name = "influenza",
+  r0 = 1.5,
+  preinfectious_period = 3,
+  infectious_period = 7
+)
+
+
+
+ +
+
+

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 the transmission rate, \(\beta\), as:

+

\[ \beta = R_0 \gamma.\]

+
+
+
+ +
+

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).

+
+
+ +
+
+

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
+
+
+
+
+
+
+ +
+
+
+

OUTPUT +

+
                 
+contact.age.group     [,1]     [,2]     [,3]
+          [0,20)  7.883663 2.794154 1.565665
+          [20,40) 3.120220 4.854839 2.624868
+          40+     3.063895 4.599893 5.005571
+
+
+
+
+
+

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 in the correct format to be used in epidemics.

+
+
+ +
+
+

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 +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).

+
+
+
+
+

Generating trajectories +

+

We have prepared our parameter values, contact matrix and demography +vector. Now we must set the initial conditions, prepare the population +and run the model.

+
+

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_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_conditions_free <- c(
+  S = 1, E = 0, I = 0, R = 0, V = 0
+)
+
+

We combine the three initial conditions vectors into one matrix,

+
+

R +

+
+# build for all age groups
+initial_conditions <- rbind(
+  initial_conditions_inf,
+  initial_conditions_free,
+  initial_conditions_free
+)
+rownames(initial_conditions) <- rownames(contact_matrix)
+initial_conditions
+
+
+

OUTPUT +

+
               S E     I R V
+[0,20)  0.999999 0 1e-06 0 0
+[20,40) 1.000000 0 0e+00 0 0
+40+     1.000000 0 0e+00 0 0
+
+
+
+

Running the model

+

To run the model we need the following inputs:

+
  • an infection object,
  • +
  • a population object,
  • +
  • an optional number of time steps.
  • +

We have already created our infection object influenza. +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_vector <- contact_data$demography$population
+names(demography_vector) <- rownames(contact_matrix)
+demography_vector
+
+
+

OUTPUT +

+
  [0,20)  [20,40)      40+ 
+14799290 16526302 28961159 
+
+

To create our population object, we call the function +population() specifying a name, the contact matrix, the +demography vector and the initial conditions.

+
+

R +

+
+uk_population <- population(
+  name = "UK",
+  contact_matrix = contact_matrix,
+  demography_vector = demography_vector,
+  initial_conditions = initial_conditions
+)
+
+

No we are ready to run our model. We will specify +time_end=600 to run the model for 600 days.

+
+

R +

+
+output <- epidemic_default_cpp(
+  population = uk_population,
+  infection = influenza,
+  time_end = 600
+)
+head(output)
+
+
+

OUTPUT +

+
   time demography_group compartment    value
+1:    0           [0,20) susceptible 14799275
+2:    0          [20,40) susceptible 16526302
+3:    0              40+ susceptible 28961159
+4:    0           [0,20)     exposed        0
+5:    0          [20,40)     exposed        0
+6:    0              40+     exposed        0
+
+

Our model output consists of the number of individuals in each +compartment in each age group through time. We can visualise the +infectious individuals only (those in the \(I\) class) through time.

+
+

R +

+
+ggplot(output[compartment == "infectious", ]) +
+  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,
+    name = "Infectious indivduals"
+  ) +
+  labs(
+    x = "Model time (days)"
+  ) +
+  theme_classic() +
+  theme(
+    legend.position = "top"
+  ) +
+  theme_grey(
+    base_size = 15
+  )
+
+
+
+ +
+
+

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 and +maximum number of time steps is days, the default increment is 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, 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
  2. +
+

R +

+
+R0_vec <- rnorm(100, 1.5, 0.05)
+
+
  1. Run the model 100 times with \(R_0\) equal to a different sample each +time
  2. +
+

R +

+
+output_samples <- Map(
+ R0_vec,
+  seq_along(R0_vec),
+  f = function(x, i) {
+  # create infection object for R0 value
+    influenza <- infection(
+      name = "influenza",
+      r0 = x,
+      preinfectious_period = 3,
+      infectious_period = 7
+    )
+
+    # run an epidemic model using `epidemic()`
+    output <- epidemic_default_cpp(
+      population = uk_population,
+      infection = influenza,
+      time_end = 600, increment = 1.0
+    )
+
+    # extract infectious individuals 
+    output <- output[compartment == "infectious"]
+
+    # assign scenario number
+    output[, c("scenario", "R") := list(i, x)]
+
+    output
+  }
+)
+
+# combine to prepare for plotting
+output_samples <- bind_rows(output_samples)
+
+
  1. Calculate the mean and 95% quantiles of number of infectious +individuals across each model simulation and visualise output
  2. +
+

R +

+
+ggplot(output_samples ,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)
+  ) +
+  theme_grey(
+    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.

+
+

Summary +

+

In this tutorial, we have learnt how to generate disease trajectories +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 +
  • +
  • Contact matrices can be estimated from different sources
  • +
  • Include uncertainty in model trajectories
  • +
+
+
+ +
+
+ + +
+
+ + + diff --git a/sitemap.xml b/sitemap.xml index cbf564ea..2b7273e4 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -12,6 +12,9 @@ https://epiverse-trace.github.io/tutorials/aio.html + + https://epiverse-trace.github.io/tutorials/compare-interventions.html + https://epiverse-trace.github.io/tutorials/images.html @@ -30,6 +33,9 @@ https://epiverse-trace.github.io/tutorials/instructor/aio.html + + https://epiverse-trace.github.io/tutorials/instructor/compare-interventions.html + https://epiverse-trace.github.io/tutorials/instructor/images.html @@ -45,12 +51,21 @@ https://epiverse-trace.github.io/tutorials/instructor/key-points.html + + https://epiverse-trace.github.io/tutorials/instructor/model-choices.html + + + https://epiverse-trace.github.io/tutorials/instructor/modelling-interventions.html + https://epiverse-trace.github.io/tutorials/instructor/profiles.html https://epiverse-trace.github.io/tutorials/instructor/reference.html + + https://epiverse-trace.github.io/tutorials/instructor/simulating-transmission.html + https://epiverse-trace.github.io/tutorials/instructor/template.html @@ -63,12 +78,21 @@ https://epiverse-trace.github.io/tutorials/key-points.html + + https://epiverse-trace.github.io/tutorials/model-choices.html + + + https://epiverse-trace.github.io/tutorials/modelling-interventions.html + https://epiverse-trace.github.io/tutorials/profiles.html https://epiverse-trace.github.io/tutorials/reference.html + + https://epiverse-trace.github.io/tutorials/simulating-transmission.html + https://epiverse-trace.github.io/tutorials/template.html