You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -213,7 +213,7 @@ There is no vaccination scheme in place
213
213
214
214
::::::::::::::::: hint
215
215
216
-
### HINT: Running the model with default parameter values
216
+
### HINT: Running the model with default parameter values
217
217
218
218
We can run the Vacamole model with [default parameter values](https://epiverse-trace.github.io/epidemics/articles/model_vacamole.html#model-epidemic-using-vacamole) by just specifying the population object and number of time steps to run the model for:
Then, we create a list of all the interventions we want to include in our comparison. We define our scenarios as follows:
417
423
418
-
+ scenario 1: close schools
419
-
+ scenario 2: mask mandate
420
-
+ scenario 3: close schools and mask mandate.
424
+
+ scenario 1: close schools
425
+
+ scenario 2: mask mandate
426
+
+ scenario 3: close schools and mask mandate.
421
427
422
428
In R we specify this as:
423
429
@@ -480,7 +486,7 @@ head(output)
480
486
481
487
Now that we have our model output for all of our scenarios, we want to compare the outputs of the interventions to our baseline.
482
488
483
-
We can do this using `outcomes_averted()` in `{epidemics}`. This function calculates the final epidemic size for each scenario, and then calculates the number of infections averted in each scenario compared to the baseline. To use this function we specify the:
489
+
We can do this using `outcomes_averted()` in `{epidemics}`. This function calculates the final epidemic size for each scenario, and then calculates the number of infections averted in each scenario compared to the baseline. To use this function we specify the:
484
490
485
491
+ output of the baseline scenario
486
492
+ outputs of the intervention scenario(s).
@@ -542,9 +548,9 @@ We recommend to read the vignette on [Modelling responses to a stochastic Ebola
542
548
543
549
::::::::::::::::::::::::::::::::::::: challenge
544
550
545
-
## Challenge: Ebola outbreak analysis
551
+
## Challenge: Ebola outbreak analysis
546
552
547
-
You have been tasked to investigate the potential impact of an intervention on an Ebola outbreak in Guinea (e.g. a reduction in risky contacts with cases). Using `model_ebola()` and the the information detailed below, find the number of infections averted when:
553
+
You have been tasked to investigate the potential impact of an intervention on an Ebola outbreak in Guinea (e.g. a reduction in risky contacts with cases). Using `model_ebola()` and the the information detailed below, find the number of infections averted when:
548
554
549
555
+ an intervention is applied to reduce the transmission rate by 50% from day 60 and,
550
556
+ an intervention is applied to reduce transmission by 10% from day 30.
@@ -553,11 +559,11 @@ For both interventions, we assume there is some uncertainty about the baseline t
553
559
554
560
*Note: Depending on the number of replicates used, this simulation may take several minutes to run.*
The basic contact matrix represents the amount of contact or mixing within and between different subgroups of a population. The subgroups are often age categories but can also be:
@@ -63,40 +57,64 @@ $$
63
57
\end{bmatrix}
64
58
$$
65
59
66
-
In this example, we would use this to represent that children meet, on average, 2 other children and 2 adult per day (first row), and adults meet, on average, 1 child and 3 other adults per day (second row). We can use this kind of information to account for the role heterogeneity in contact plays in infectious disease transmission.
60
+
In this example, we would use this to represent that children meet, on average, 2 other children and 2 adult per day (first row), and adults meet, on average, 1 child and 3 other adults per day (second row). We can use this kind of information to account for the role that heterogeneity in contact plays in infectious disease transmission.
67
61
68
62
::::::::::::::::::::::::::::::::::::: callout
69
63
70
64
### A Note on Notation
71
-
For a contact matrix with rows $i$ and columns $j$:
65
+
In a contact matrix, the entry $C[i,j]$, at row $i$ and column $j$:
72
66
73
-
-$C[i,j]$ represents the average number of contacts that individuals in group $i$ have with individuals in group $j$
74
-
- This average is calculated as the total number of contacts between groups $i$ and $j$, divided by the number of individuals in group $i$
67
+
- Represents the average number of contacts an individual in group $i$ has with individuals in group $j$
68
+
- This is calculated by dividing the total number of contacts between groups $i$ and $j$by the size of group $i$
75
69
::::::::::::::::::::::::::::::::::::::::::::::::
76
70
77
71
## Using `socialmixr`
78
72
79
73
Contact matrices are commonly estimated from studies that use diaries to record interactions. For example, the POLYMOD survey measured contact patterns in 8 European countries using data on the location and duration of contacts reported by the study participants [(Mossong et al. 2008)](https://doi.org/10.1371/journal.pmed.0050074).
80
74
81
-
The R package `{socialmixr}` contains functions which can estimate contact matrices from POLYMOD and other surveys. We can load the POLYMOD survey data:
75
+
The R package `{socialmixr}` contains functions which can estimate contact matrices from POLYMOD and other surveys. We can download and load the POLYMOD survey data directly from Zenodo using `{contactsurveys}` and `{socialmixr}`:
Then we can obtain the contact matrix for the age categories we want by specifying `age_limits`.
102
+
Always pass the `countries =` argument to `contact_matrix()` to make sure you use data from the intended country only.
103
+
104
+
::::::::::::::::::::::::::::::::::::::::::::::::
105
+
106
+
Then we can obtain the contact matrix for the age categories we want by specifying `age_limits`. We also add `return_demography = TRUE` to include demographic information in the output, which is required when using the contact matrix with `{epidemics}`.
90
107
91
108
92
109
```r
93
-
contact_data<-socialmixr::contact_matrix(
94
-
survey=polymod,
110
+
contacts_byage<-socialmixr::contact_matrix(
111
+
survey=survey_load,
95
112
countries="United Kingdom",
96
113
age_limits= c(0, 20, 40),
97
-
symmetric=TRUE
114
+
symmetric=TRUE,
115
+
return_demography=TRUE
98
116
)
99
-
contact_data
117
+
contacts_byage
100
118
```
101
119
102
120
```output
@@ -124,9 +142,9 @@ $participants
124
142
125
143
126
144
127
-
**Note: although the contact matrix `contact_data$matrix` is not itself mathematically symmetric, it satisfies the condition that the total number of contacts of one group with another is the same as the reverse. In other words:
For the mathematical explanation see [the corresponding section in the socialmixr documentation](https://epiforecasts.io/socialmixr/articles/socialmixr.html#symmetric-contact-matrices).**
145
+
**Note**: although the contact matrix `contacts_byage$matrix` is not itself mathematically symmetric, it satisfies the condition that the total number of contacts of one group with another is the same as the reverse. In other words:
For the mathematical explanation see [the corresponding section in the socialmixr documentation](https://epiforecasts.io/socialmixr/articles/socialmixr.html#symmetric-contact-matrices).
130
148
131
149
132
150
::::::::::::::::::::::::::::::::::::: callout
@@ -145,14 +163,17 @@ If `symmetric` is set to TRUE, the `contact_matrix()` function will internally u
145
163
146
164
::::::::::::::::::::::::::::::::::::::::::::::::
147
165
148
-
The example above uses the POLYMOD survey. There are a number of surveys available in `socialmixr`. To list the available surveys, use `socialmixr::list_surveys()`. To download a survey, we can use `socialmixr::get_survey()`
166
+
The example above uses the POLYMOD survey. There are a number of surveys available in `socialmixr`. To list the available surveys, use `socialmixr::list_surveys()`. To download a survey from Zenodo and load it, we use `contactsurveys::download_survey()` followed by `socialmixr::load_survey()`:
149
167
150
168
151
169
```r
152
-
# Access the contact survey data from Zenodo
153
-
zambia_sa_survey<-socialmixr::get_survey(
154
-
"https://doi.org/10.5281/zenodo.3874675"
170
+
# Download and load the contact survey data for Zambia from Zenodo
# Print the vector of population size for {epidemics}
256
-
contact_data_zambia$demography$population
278
+
contacts_byage_zambia$demography$population
257
279
```
258
280
259
281
```output
@@ -269,8 +291,6 @@ Contact matrices can be estimated from data obtained from diary (such as POLYMOD
269
291
::::::::::::::::::::::::::::::::::::::::::::::::
270
292
271
293
272
-
273
-
274
294
## Analyses with contact matrices
275
295
276
296
Contact matrices can be used in a wide range of epidemiological analyses, they can be used:
@@ -293,7 +313,7 @@ Whereas a contact matrix gives the average number of contacts that one groups ma
293
313
294
314
### In mathematical models
295
315
296
-
Consider the SIR model where individuals are categorized as either susceptible $S$, infected but not yet infectious $E$, infectious $I$ or recovered $R$. The schematic below shows the processes which describe the flow of individuals between the disease states $S$, $I$ and $R$ and the key parameters for each process.
316
+
Consider the SIR model where individuals are categorized as either susceptible $S$, infected $I$ and recovered $R$. The schematic below shows the processes which describe the flow of individuals between the disease states $S$, $I$ and $R$ and the key parameters for each process.
To add age structure to our model, we need to add additional equations for the infection states $S$, $I$ and $R$ for each age group $i$. If we want to assume that there is heterogeneity in contacts between age groups then we must adapt the transmission term $\beta SI$ to include the contact matrix $C$ as follows:
331
+
To add age structure to our model, we need to add additional equations for the infection states $S$, $I$ and $R$ for each age group $i$. If we want to assume that there is heterogeneity in contacts between age groups then we must adapt the transmission term $\beta SI$ to include the contact matrix $C$ as follows:
312
332
313
333
$$ \beta S_i \sum_j C_{i,j} I_j/N_j. $$
314
334
315
-
Susceptible individuals in age group $i$ become infected dependent on their rate of contact with individuals in each age group. For each disease state ($S$, $E$, $I$ and $R$) and age group ($i$), we have a differential equation describing the rate of change with respect to time.
335
+
Susceptible individuals in age group $i$ become infected dependent on their rate of contact with individuals in each age group. For each disease state ($S$, $I$ and $R$) and age group ($i$), we have a differential equations describing the rate of change with respect to time.
316
336
317
337
$$
318
338
\begin{aligned}
@@ -329,13 +349,13 @@ When simulating an epidemic, we often want to ensure that the average number of
329
349
330
350
Rather than just using the raw number of contacts, we can instead normalise the contact matrix to make it easier to work in terms of $R_0$. In particular, we normalise the matrix by scaling it so that if we were to calculate the average number of secondary cases based on this normalised matrix, the result would be 1 (in mathematical terms, we are scaling the matrix so the largest eigenvalue is 1). This transformation scales the entries but preserves their relative values.
331
351
332
-
In the case of the above model, we want to define $\beta C_{i,j}$ so that the model has a specified valued of $R_0$. If the entry of the contact matrix $C[i,j]$ represents the contacts of population $i$ with $j$, it is equivalent to `contact_data$matrix[i,j]`, and the maximum eigenvalue of this matrix represents the typical magnitude of contacts, not typical magnitude of transmission. We must therefore normalise the matrix $C$ so the maximum eigenvalue is one; we call this matrix $C_{normalised}$. Because the rate of recovery is $\gamma$, individuals will be infectious on average for $1/\gamma$ days. So $\beta$ as a model input is calculated from $R_0$, the scaling factor and the value of $\gamma$ (i.e. mathematically we use the fact that the dominant eigenvalue of the matrix $R_0 \times C_{normalised}$ is equal to $\beta / \gamma$).
352
+
In the case of the above model, we want to define $\beta C_{i,j}$ so that the model has a specified valued of $R_0$. If the entry of the contact matrix $C[i,j]$ represents the contacts of population $i$ with $j$, it is equivalent to `contacts_byage$matrix[i,j]`, and the maximum eigenvalue of this matrix represents the typical magnitude of contacts, not typical magnitude of transmission. We must therefore normalise the matrix $C$ so the maximum eigenvalue is one; we call this matrix $C_{normalised}$. Because the rate of recovery is $\gamma$, individuals will be infectious on average for $1/\gamma$ days. So $\beta$ as a model input is calculated from $R_0$, the scaling factor and the value of $\gamma$ (i.e. mathematically we use the fact that the dominant eigenvalue of the matrix $R_0 \times C_{normalised}$ is equal to $\beta / \gamma$).
0 commit comments