Skip to contents

bsts Model Wrapper

Usage

bsts_model(y = NULL, samples = NULL, horizon = NULL, model = NULL)

Arguments

y

Numeric vector of time points to forecast

samples

Numeric, number of samples to take.

horizon

Numeric, the time horizon over which to predict.

model

A bsts model object wrapped in a function with an ss and y argument.

Value

A dataframe of predictions (with columns representing the time horizon and rows representing samples).

Examples

if (FALSE) {

library(bsts)

## Used on its own
bsts_model(
  y = EpiSoon::example_obs_rts[1:10, ]$rt,
  model = function(ss, y) {
    bsts::AddAr(ss, y = y, lags = 2)
  },
  samples = 10, horizon = 7
)

## Used for forecasting
forecast_rt(EpiSoon::example_obs_rts[1:10, ],
  model = function(...) {
    EpiSoon::bsts_model(
      model =
        function(ss, y) {
          bsts::AddAr(ss, y = y, lags = 3)
        }, ...
    )
  },
  horizon = 7, samples = 10
)
}