Calculate a reproduction number estimate from incidence data using the EpiEstim library and an empirical generation time distribution. This uses resampling to transmit uncertainty in generation time estimates. This is quite slow for each time series depending on the number of bootstraps and samples in the infectivity profile.
Usage
rt_epiestim(
df = i_incidence_input,
ip = i_infectivity_profile,
bootstraps = 2000,
window = 14,
mean_prior = 1,
std_prior = 2,
...
)
Arguments
- df
Count data. Extra groups are allowed.
A dataframe containing the following columns:
count (positive_integer) - Positive case counts associated with the specified timeframe
time (as.time_period + group_unique) - A (usually complete) set of singular observations per unit time as a `time_period`
Ungrouped.
No default value.
- ip
infectivity profile
A dataframe containing the following columns:
boot (anything) - a bootstrap identifier
time (positive_double) - the end of the time period (in days)
probability (proportion) - the probability of infection between previous time period until `time`
Must be grouped by: boot (exactly).
A default value is defined.
- bootstraps
the number of bootstraps to take to calculate for each point.
- window
the width of the epiestim window
- mean_prior
the prior for the $R_t$ estimate. When sample size is low the $R_t$ estimate will revert to this prior. In EpiEstim the default is a high number to allow detection of insufficient data but this tends to create anomalies in the early part of infection timeseries. A possible value is $R_0$ but in fact this also will be a poor choice for the value of $R_t$ when case numbers drop to a low value.
- std_prior
the prior for the $R_t$ SD.
- ...
not used
Value
A dataframe containing the following columns:
time (as.time_period + group_unique) - A (usually complete) set of singular observations per unit time as a
time_period
rt.fit (double) - an estimate of the reproduction number
rt.se.fit (double) - the standard error of the reproduction number
rt.0.025 (double) - lower confidence limit of the reproduction number
rt.0.5 (double) - median estimate of the reproduction number
rt.0.975 (double) - upper confidence limit of the reproduction number
No mandatory groupings.
No default value.
Examples
tmp = growthrates::england_covid %>%
time_aggregate(count=sum(count))
if (FALSE) {
# not run due to long running
tmp2 = tmp %>% rt_epiestim()
}