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,62 @@ $$
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
+
::::::::::::::::::::::::::::::::::::::::::::::::
103
+
104
+
We obtain the contact matrix for the United Kingdom — passing `countries = "United Kingdom"` to select data from the intended country, `age_limits` to define age categories, and `return_demography = TRUE` to include demographic information required by `{epidemics}`.
90
105
91
106
92
107
```r
93
-
contact_data<-socialmixr::contact_matrix(
94
-
survey=polymod,
108
+
contacts_byage<-socialmixr::contact_matrix(
109
+
survey=survey_load,
95
110
countries="United Kingdom",
96
111
age_limits= c(0, 20, 40),
97
-
symmetric=TRUE
112
+
symmetric=TRUE,
113
+
return_demography=TRUE
98
114
)
99
-
contact_data
115
+
contacts_byage
100
116
```
101
117
102
118
```output
@@ -124,9 +140,9 @@ $participants
124
140
125
141
126
142
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).**
143
+
**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
146
131
147
132
148
::::::::::::::::::::::::::::::::::::: callout
@@ -145,30 +161,40 @@ If `symmetric` is set to TRUE, the `contact_matrix()` function will internally u
145
161
146
162
::::::::::::::::::::::::::::::::::::::::::::::::
147
163
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()`
164
+
The example above uses the POLYMOD survey. Other surveys are available in the [Zenodo Social Contact Data community](https://zenodo.org/communities/social_contact_data/). To use a different survey, first identify its DOI (see below), then download and load it with `contactsurveys::download_survey()` and `socialmixr::load_survey()`. Here we use the Zambia and South Africa contact survey:
149
165
150
166
151
167
```r
152
-
# Access the contact survey data from Zenodo
153
-
zambia_sa_survey<-socialmixr::get_survey(
154
-
"https://doi.org/10.5281/zenodo.3874675"
168
+
# Download and load the contact survey data for Zambia from Zenodo
You can explore all the available surveys from the Zenodo repository at <https://zenodo.org/communities/social_contact_data/>. If you are interested in accessing to a specific URL within R, you can try:
179
+
**Find a survey DOI with contactsurveys**
161
180
162
-
```r
163
-
library(socialmixr)
181
+
Browse available surveys in the [Zenodo Social Contact Data community](https://zenodo.org/communities/social_contact_data/), or list them programmatically:
182
+
183
+
184
+
```r
185
+
library(contactsurveys)
164
186
library(tidyverse)
165
187
166
-
# Get URL for Zambia contact survey data from {socialmixr}
167
-
socialmixr::list_surveys() %>%
188
+
# Get URL for Zambia contact survey data from {contactsurveys}
@@ -188,12 +214,12 @@ The R package {socialmixr} contains functions which can estimate contact matrice
188
214
189
215
::::::::::::::::::::: hint
190
216
191
-
The survey object `zambia_sa_survey` contains data from two countries. If you need to estimate the social contact matrix from data of the specific country of Zambia, identify what argument in `socialmixr::contact_matrix()` you need for this.
217
+
The survey object `survey_load_zambia` contains data from two countries. If you need to estimate the social contact matrix from data of the specific country of Zambia, identify what argument in `socialmixr::contact_matrix()` you need for this.
192
218
193
219
194
220
```r
195
221
# Inspect the countries within the survey object
196
-
levels(zambia_sa_survey$participants$country)
222
+
levels(survey_load_zambia$participants$country)
197
223
```
198
224
199
225
```output
@@ -211,11 +237,12 @@ Similar to the code above, to access vector values within a dataframe, you can u
# Print the vector of population size for {epidemics}
256
-
contact_data_zambia$demography$population
283
+
contacts_byage_zambia$demography$population
257
284
```
258
285
259
286
```output
@@ -269,8 +296,6 @@ Contact matrices can be estimated from data obtained from diary (such as POLYMOD
269
296
::::::::::::::::::::::::::::::::::::::::::::::::
270
297
271
298
272
-
273
-
274
299
## Analyses with contact matrices
275
300
276
301
Contact matrices can be used in a wide range of epidemiological analyses, they can be used:
@@ -293,7 +318,7 @@ Whereas a contact matrix gives the average number of contacts that one groups ma
293
318
294
319
### In mathematical models
295
320
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.
321
+
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:
336
+
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
337
313
338
$$ \beta S_i \sum_j C_{i,j} I_j/N_j. $$
314
339
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.
340
+
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
341
317
342
$$
318
343
\begin{aligned}
@@ -329,13 +354,13 @@ When simulating an epidemic, we often want to ensure that the average number of
329
354
330
355
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
356
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$).
357
+
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