This function forecasts secondary observations using the output of
estimate_secondary() and either
observed primary data or a forecast of primary observations. See the examples of
for one use case. It can also be combined with
estimate_infections() to produce a forecast for a secondary
observation from a forecast of a primary observation. See the examples of
example use cases on synthetic data. See here
for an example of forecasting Covid-19 deaths from Covid-19 cases.
forecast_secondary( estimate, primary, primary_variable = "reported_cases", model = NULL, samples = NULL, all_dates = FALSE, CrIs = c(0.2, 0.5, 0.9) )
An object of class "estimate_secondary" as produced by
A data.frame containing at least
value (integer) variables and optionally
sample. Used as the primary observation used to forecast the secondary observations. Alternatively,
this may be an object of class "estimate_infections" as produced by
is of class "estimate_infections" then the internal samples will be filtered to have a minimum date ahead of
those observed in the
A character string indicating the primary variable, defaulting to "reported_cases". Only used when primary is of class "estimate_infections".
A compiled stan model as returned by
Numeric, number of posterior samples to simulate from. The default is to use all
samples in the
primary input when present. If not present the default is to use 1000 samples.
Logical, defaults to FALSE. Should a forecast for all dates and not just those in the forecast horizon be returned.
Numeric vector of credible intervals to calculate.
A list containing:
predictions (a data frame ordered by date with the primary,
and secondary observations, and a summary of the forecast secondary observations. For primary
observations in the forecast horizon when uncertainty is present the median is used),
samples a data frame of forecast secondary observation posterior samples, and
summary of the forecast secondary observation posterior.