epinow {EpiNow2} | R Documentation |
Real-time Rt Estimation, Forecasting and Reporting
Description
This function wraps the functionality of
estimate_infections()
in order
to estimate Rt and cases by date of infection and forecast these infections
into the future. In addition to the functionality of
estimate_infections()
it produces additional summary output useful for
reporting results and interpreting them as well as error catching and
reporting, making it particularly useful for production use e.g. running at
set intervals on a dedicated server.
Usage
epinow(
data,
generation_time = generation_time_opts(),
delays = delay_opts(),
truncation = trunc_opts(),
rt = rt_opts(),
backcalc = backcalc_opts(),
gp = gp_opts(),
obs = obs_opts(),
stan = stan_opts(),
horizon = 7,
CrIs = c(0.2, 0.5, 0.9),
filter_leading_zeros = TRUE,
zero_threshold = Inf,
return_output = FALSE,
output = c("samples", "plots", "latest", "fit", "timing"),
plot_args = list(),
target_folder = NULL,
target_date,
logs = tempdir(),
id = "epinow",
verbose = interactive(),
reported_cases
)
Arguments
data |
A |
generation_time |
A call to |
delays |
A call to |
truncation |
A call to |
rt |
A list of options as generated by |
backcalc |
A list of options as generated by |
gp |
A list of options as generated by |
obs |
A list of options as generated by |
stan |
A list of stan options as generated by |
horizon |
Numeric, defaults to 7. Number of days into the future to forecast. |
CrIs |
Numeric vector of credible intervals to calculate. |
filter_leading_zeros |
Logical, defaults to TRUE. Should zeros at the start of the time series be filtered out. |
zero_threshold |
|
return_output |
Logical, defaults to FALSE. Should output be returned, this automatically updates to TRUE if no directory for saving is specified. |
output |
A character vector of optional output to return. Supported
options are samples ("samples"), plots ("plots"), the run time ("timing"),
copying the dated folder into a latest folder (if |
plot_args |
A list of optional arguments passed to |
target_folder |
Character string specifying where to save results (will create if not present). |
target_date |
Date, defaults to maximum found in the data if not specified. |
logs |
Character path indicating the target folder in which to store log
information. Defaults to the temporary directory if not specified. Default
logging can be disabled if |
id |
A character string used to assign logging information on error.
Used by |
verbose |
Logical, defaults to |
reported_cases |
Deprecated; use |
Value
A list of output from estimate_infections with additional elements summarising results and reporting errors if they have occurred.
See Also
estimate_infections()
forecast_infections()
regional_epinow()
Examples
# set number of cores to use
old_opts <- options()
options(mc.cores = ifelse(interactive(), 4, 1))
# set an example generation time. In practice this should use an estimate
# from the literature or be estimated from data
generation_time <- Gamma(
shape = Normal(1.3, 0.3),
rate = Normal(0.37, 0.09),
max = 14
)
# set an example incubation period. In practice this should use an estimate
# from the literature or be estimated from data
incubation_period <- LogNormal(
meanlog = Normal(1.6, 0.06),
sdlog = Normal(0.4, 0.07),
max = 14
)
# set an example reporting delay. In practice this should use an estimate
# from the literature or be estimated from data
reporting_delay <- LogNormal(mean = 2, sd = 1, max = 10)
# example case data
reported_cases <- example_confirmed[1:40]
# estimate Rt and nowcast/forecast cases by date of infection
out <- epinow(
reported_cases = reported_cases,
generation_time = generation_time_opts(generation_time),
rt = rt_opts(prior = list(mean = 2, sd = 0.1)),
delays = delay_opts(incubation_period + reporting_delay)
)
# summary of the latest estimates
summary(out)
# plot estimates
plot(out)
# summary of R estimates
summary(out, type = "parameters", params = "R")
options(old_opts)