| as_forecast_sample | R Documentation |
forecast_sample object
Convert outputs of EpiNow2 fitting and forecasting functions to
forecast_sample objects via scoringutils::as_forecast_sample() for
evaluating predictive performance. Methods are provided for objects
returned by epinow(), estimate_infections(), forecast_secondary(),
and estimate_truncation().
These methods extract sample-level posterior predictions via
get_predictions() with format = "sample", merge them with the supplied
observations on date, and pass the result to
scoringutils::as_forecast_sample().
scoringutils is an optional dependency; calling these methods without it installed gives an informative error.
## S3 method for class 'estimate_infections'
as_forecast_sample(data, observations, horizon = 0, ...)
## S3 method for class 'epinow'
as_forecast_sample(data, observations, horizon = 0, ...)
## S3 method for class 'forecast_secondary'
as_forecast_sample(data, observations, horizon = 0, ...)
## S3 method for class 'estimate_truncation'
as_forecast_sample(data, observations, horizon = -Inf, ...)
data |
Output of |
observations |
A |
horizon |
Numeric scalar lower bound on the |
... |
Additional arguments passed to
|
A forecast_sample object as returned by
scoringutils::as_forecast_sample(). Rows for which observations does
not provide a value on the corresponding date are dropped.
get_predictions() for the underlying sample extraction.
library(scoringutils)
# samples and calculation time have been reduced for this example
# for real analyses, use at least samples = 2000
fit <- estimate_infections(example_confirmed[1:40],
generation_time = gt_opts(example_generation_time),
delays = delay_opts(example_incubation_period + example_reporting_delay),
rt = rt_opts(prior = LogNormal(mean = 2, sd = 0.2)),
stan = stan_opts(samples = 100, warmup = 200)
)
forecast_obj <- as_forecast_sample(fit, observations = example_confirmed)
score(forecast_obj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.