Skip to contents

Fit and Forecast using a Model

Usage

forecast_rt(
  rts,
  model,
  horizon = 7,
  samples = 1000,
  bound_rt = TRUE,
  timeout = 100
)

Arguments

rts

A dataframe of containing two variables rt and date with rt being numeric and date being a date.

model

A model object in the format of bsts_model or fable_model. See the corresponding help files for details.

horizon

Numeric, the time horizon over which to predict.

samples

Numeric, number of samples to take.

bound_rt

Logical, defaults to TRUE. Should Rt values be bounded to be greater than or equal to 0.

timeout

Numeric, timeout of model fitting in seconds. Defaults to 30 seconds.

Value

A dataframe of samples containing the following variables: sample, date, rt, and horizon.

Examples

if (FALSE) {
forecast_rt(EpiSoon::example_obs_rts[1:10, ],
  model = function(...) {
    EpiSoon::bsts_model(model = function(ss, y) {
      bsts::AddAutoAr(ss, y = y, lags = 10)
    }, ...)
  },
  horizon = 7, samples = 10
)
}