Calculate a reproduction number estimate from modelled incidence using the
methods described in the vignette "Estimating the reproduction number from
modelled incidence" and using a set of empirical generation time
distributions. This assumes that modelled incidence has the same time unit as
the ip
distribution, and that this is daily, if this is not the case then
rescale_model()
may be able to fix it.
Usage
rt_from_incidence(
df = i_incidence_model,
ip = i_discrete_ip,
approx = FALSE,
.progress = interactive()
)
Arguments
- df
modelled incidence estimate - a dataframe with columns:
time (ggoutbreak::time_period + group_unique) - A (usually complete) set of singular observations per unit time as a `time_period`
incidence.fit (double) - an estimate of the incidence rate on a log scale
incidence.se.fit (positive_double) - the standard error of the incidence rate estimate on a log scale
incidence.0.025 (positive_double) - lower confidence limit of the incidence rate (true scale)
incidence.0.5 (positive_double) - median estimate of the incidence rate (true scale)
incidence.0.975 (positive_double) - upper confidence limit of the incidence rate (true scale)
Any grouping allowed.
- ip
an infectivity profile (aka generation time distribution) - a dataframe with columns:
boot (anything + default(1)) - a bootstrap identifier
probability (proportion) - the probability of new event during this period.
tau (integer + complete) - the days since the index event.
Minimally grouped by: boot (and other groupings allowed).
A default value is defined.
- approx
use a faster, but approximate, estimate of quantiles
- .progress
show a CLI progress bar
Value
A dataframe containing the following columns:
time (ggoutbreak::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 (positive_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
Any grouping allowed.
Examples
tmp = ggoutbreak::england_covid %>%
dplyr::filter(date < "2021-01-01") %>%
time_aggregate(count=sum(count)) %>%
poisson_locfit_model() %>%
rt_from_incidence()
if (interactive()) {
plot_rt(tmp, date_labels="%b %y") %above%
ggplot2::geom_errorbar(
data=england_consensus_rt %>% dplyr::filter(date < "2021-01-01"),
mapping=ggplot2::aes(x=date-14,ymin=low,ymax=high),colour="grey60")+
ggplot2::coord_cartesian(ylim=c(0.5,1.75),xlim=as.Date(c("2020-05-01",NA)))
}