Skip to content

Commit c5471a6

Browse files
committed
collect feedback + solve lintr checks
epiverse-trace/tutorials-early#37
1 parent 578de0b commit c5471a6

File tree

1 file changed

+44
-30
lines changed

1 file changed

+44
-30
lines changed

episodes/quantify-transmissibility.Rmd

+44-30
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ withr::local_options(list(mc.cores = 4))
1313
:::::::::::::::::::::::::::::::::::::: questions
1414

1515
- How can I estimate the time-varying reproduction number ($Rt$) and growth rate from a time series of case data?
16-
- How can I quantify geographical heterogeneity in these transmission metrics?
16+
- How can I quantify geographical heterogeneity from these transmission metrics?
1717

1818

1919
::::::::::::::::::::::::::::::::::::::::::::::::
@@ -28,11 +28,11 @@ withr::local_options(list(mc.cores = 4))
2828

2929
## Prerequisites
3030

31-
Learners should familiarise themselves with following concept dependencies before working through this tutorial:
31+
Learners should familiarise themselves with following concepts before working through this tutorial:
3232

33-
**Statistics** : probability distributions, principle of Bayesian analysis.
33+
**Statistics**: probability distributions, principle of Bayesian analysis.
3434

35-
**Epidemic theory** : Effective reproduction number.
35+
**Epidemic theory**: Effective reproduction number.
3636

3737
:::::::::::::::::::::::::::::::::
3838

@@ -50,10 +50,9 @@ But in an ongoing outbreak, the population does not remain entirely susceptible
5050

5151
## Introduction
5252

53-
Quantifying transmission metrics at the start of an outbreak can give important information on the strength of transmission (reproduction number) and the speed of transmission ([growth rate](../learners/reference.md#growth), doubling/halving time). To estimate these key metrics using case data we must account for delays between the date of infections and date of reported cases. In an outbreak situation, data are usually available on reported dates only, therefore we must use estimation methods to account for these delays when trying to understand changes in transmission over time.
53+
The transmission intensity of an outbreak is quantified using two key metrics: the reproduction number, which informs on the strength of the transmission by indicating how many new cases are expected from each existing case; and the [growth rate](../learners/reference.md#growth), which informs on the speed of the transmission by indicating how rapidly the outbreak is spreading or declining (doubling/halving time) within a population. To estimate these key metrics using case data we must account for delays between the date of infections and date of reported cases. In an outbreak situation, data are usually available on reported dates only, therefore we must use estimation methods to account for these delays when trying to understand changes in transmission over time. For more details on the distinction between speed and strength of transmission and implications for control, see [Dushoff & Park, 2021](https://royalsocietypublishing.org/doi/full/10.1098/rspb.2020.1556).
5454

55-
In the next tutorials we will focus on how to implement the functions in `{EpiNow2}` to estimate transmission metrics of case data. We will not cover the theoretical background of the models or inference framework, for details on these concepts see the [vignette](https://epiforecasts.io/EpiNow2/dev/articles/estimate_infections.html).
56-
For more details on the distinction between speed and strength of transmission and implications for control, see [Dushoff & Park, 2021](https://royalsocietypublishing.org/doi/full/10.1098/rspb.2020.1556).
55+
In the next tutorials we will focus on how to use the functions in `{EpiNow2}` to estimate transmission metrics of case data. We will not cover the theoretical background of the models or inference framework, for details on these concepts see the [vignette](https://epiforecasts.io/EpiNow2/dev/articles/estimate_infections.html).
5756

5857

5958
::::::::::::::::::::::::::::::::::::: callout
@@ -70,14 +69,14 @@ In Bayesian inference, we use prior knowledge (prior distributions) with data (i
7069

7170
:::::::::::::::::::::::::::::::::::::::::::::::: instructor
7271

73-
We refer to the Prior probability distribution and the [Posterior probability](https://en.wikipedia.org/wiki/Posterior_probability) distribution.
72+
Refer to the prior probability distribution and the [posterior probability](https://en.wikipedia.org/wiki/Posterior_probability) distribution.
7473

75-
Lines below, in the "`Expected change in daily cases`" callout, by "the posterior probability that $R_t < 1$", we refer specifically to the [area under the posterior probability distribution curve](https://www.nature.com/articles/nmeth.3368/figures/1).
74+
In the ["`Expected change in daily cases`" callout](#expected-change-in-daily-cases), by "the posterior probability that $R_t < 1$", we refer specifically to the [area under the posterior probability distribution curve](https://www.nature.com/articles/nmeth.3368/figures/1).
7675

7776
::::::::::::::::::::::::::::::::::::::::::::::::
7877

7978

80-
The first step is to load the `{EpiNow2}` package :
79+
The first step is to load the `{EpiNow2}` package:
8180

8281
```{r, eval = FALSE}
8382
library(EpiNow2)
@@ -101,31 +100,46 @@ dplyr::as_tibble(incidence2::covidregionaldataUK)
101100

102101
To use the data, we must format the data to have two columns:
103102

104-
+ `date` : the date (as a date object see `?is.Date()`),
105-
+ `confirm` : number of confirmed cases on that date.
103+
+ `date`: the date (as a date object see `?is.Date()`),
104+
+ `confirm`: number of confirmed cases on that date.
106105

107-
Let's use `{tidyr}` and `incidence2::incidence()` for this:
106+
Let's use `{dplyr}` for this:
108107

109108
```{r, warning = FALSE, message = FALSE}
109+
library(dplyr)
110+
111+
cases <- incidence2::covidregionaldataUK %>%
112+
select(date, cases_new) %>%
113+
group_by(date) %>%
114+
summarise(confirm = sum(cases_new, na.rm = TRUE)) %>%
115+
ungroup()
116+
```
117+
118+
::::::::::::::::::::::::: spoiler
119+
120+
### When to use incidence2?
121+
122+
We can also use the `{incidence2}` package to aggregate cases. However, if you ever need to aggregate you data in a different time **interval** (i.e., days, weeks or months) or per **group** categories, we recommend you to explore the `incidence2::incidence()` function:
123+
124+
```{r, warning = FALSE, message = FALSE, eval=FALSE}
110125
library(tidyr)
111126
library(dplyr)
112127
113-
cases <- incidence2::covidregionaldataUK %>%
128+
incidence2::covidregionaldataUK %>%
114129
# preprocess missing values
115-
tidyr::replace_na(list(cases_new = 0)) %>%
130+
tidyr::replace_na(list(cases_new = 0)) %>%
116131
# compute the daily incidence
117132
incidence2::incidence(
118133
date_index = "date",
119134
counts = "cases_new",
120-
interval = "day",
121-
# rename column outputs to fit {EpiNow2} input
122-
date_names_to = "date",
123-
count_values_to = "confirm"
124-
) %>%
125-
# optional, but does not affect {EpiNow2} input
126-
select(-count_variable)
135+
groups = "region",
136+
interval = "week"
137+
)
127138
```
128139

140+
You can also estimate transmission metrics from {incidence2} objects using the `{i2extras}` package. Read further in the [Fitting curves](https://www.reconverse.org/i2extras/articles/fitting_epicurves.html) vignette!
141+
142+
:::::::::::::::::::::::::
129143

130144
There are case data available for `r dim(cases)[1]` days, but in an outbreak situation it is likely we would only have access to the beginning of this data set. Therefore we assume we only have the first 90 days of this data.
131145

@@ -140,7 +154,7 @@ ggplot(cases[1:90, ], aes(x = date, y = confirm)) +
140154

141155

142156
### Delay distributions
143-
We assume there are delays from the time of infection until the time a case is reported. We specify these delays as distributions to account for the uncertainty in individual level differences. The delay can consist of multiple types of delays/processes. A typical delay from time of infection to case reporting may consist of :
157+
We assume there are delays from the time of infection until the time a case is reported. We specify these delays as distributions to account for the uncertainty in individual level differences. The delay can consist of multiple types of delays/processes. A typical delay from time of infection to case reporting may consist of:
144158

145159
<p class="text-center" style="background-color: aliceblue">**time from infection to symptom onset** (the [incubation period](../learners/reference.md#incubation)) + **time from symptom onset to case notification** (the reporting time)
146160
.</p>
@@ -149,7 +163,7 @@ The delay distribution for each of these processes can either estimated from dat
149163

150164
::::::::::::::::::::::::::::::::::::: callout
151165
### Delays and data
152-
The number of delays and type of delay is a flexible input that depends on the data. The examples below highlight how the delays can be specified for different data sources:
166+
The number of delays and type of delay are a flexible input that depend on the data. The examples below highlight how the delays can be specified for different data sources:
153167

154168
<center>
155169

@@ -168,7 +182,7 @@ The number of delays and type of delay is a flexible input that depends on the d
168182

169183
#### Incubation period distribution
170184

171-
The distribution of incubation period can usually be obtained from the literature. The package `{epiparameter}` contains a library of epidemiological parameters for different diseases obtained from the literature.
185+
The distribution of incubation period for many diseases can usually be obtained from the literature. The package `{epiparameter}` contains a library of epidemiological parameters for different diseases obtained from the literature.
172186

173187
We specify a (fixed) gamma distribution with mean $\mu = 4$ and standard deviation $\sigma= 2$ (shape = $4$, scale = $1$) using the function `dist_spec()` as follows:
174188

@@ -326,7 +340,7 @@ generation_time_fixed <- dist_spec(
326340
)
327341
```
328342

329-
*Note : in the code below fixed distributions are used instead of variable. This is to speed up computation time. It is generally recommended to use variable distributions that account for additional uncertainty.*
343+
*Note: in the code below fixed distributions are used instead of variable. This is to speed up computation time. It is generally recommended to use variable distributions that account for additional uncertainty.*
330344

331345
::::::::::::::::::::::::::::::::: spoiler
332346

@@ -426,9 +440,9 @@ A factor describing expected change in daily cases based on the posterior probab
426440

427441
The outbreak data of the start of the COVID-19 pandemic from the United Kingdom from the R package `{incidence2}` includes the region in which the cases were recorded. To find regional estimates of the effective reproduction number and cases, we must format the data to have three columns:
428442

429-
+ `date` : the date,
430-
+ `region` : the region,
431-
+ `confirm` : number of confirmed cases for a region on a given date.
443+
+ `date`: the date,
444+
+ `region`: the region,
445+
+ `confirm`: number of confirmed cases for a region on a given date.
432446

433447
```{r}
434448
regional_cases <-
@@ -464,7 +478,7 @@ estimates_regional$summary$plots$R
464478

465479
## Summary
466480

467-
`EpiNow2` can be used to estimate transmission metrics from case data at the start of an outbreak. The reliability of these estimates depends on the quality of the data and appropriate choice of delay distributions. In the next tutorial we will learn how to make forecasts and investigate some of the additional inference options available in `EpiNow2`.
481+
`EpiNow2` can be used to estimate transmission metrics from case data at any time in the course of an outbreak. The reliability of these estimates depends on the quality of the data and appropriate choice of delay distributions. In the next tutorial we will learn how to make forecasts and investigate some of the additional inference options available in `EpiNow2`.
468482

469483
::::::::::::::::::::::::::::::::::::: keypoints
470484

0 commit comments

Comments
 (0)