Learn R Programming

bsts (version 0.6.1)

bsts.prediction.errors: One step prediction errors

Description

Computes the one-step-ahead prediction errors for a model of class bsts.

Usage

bsts.prediction.errors(bsts.object,
                       newdata,
                       burn = SuggestBurn(.1, bsts.object),
                       na.action = na.omit)

Arguments

bsts.object
An object of class bsts.
newdata
An optional holdout sample of data. If bsts.object contains a regression component then this must be a data.frame with all the relevant variables in the model formula for
burn
An integer giving the number of MCMC iterations to discard as burn-in. If burn <= 0<="" code=""> then no burn-in sample will be discarded.
na.action
A function determining what should be done with missing values in newdata.

Value

  • A matrix of draws of the one-step-ahead prediction errors. Rows of the matrix correspond to MCMC draws. Columns correspond to time.

References

Harvey (1990), "Forecasting, structural time series, and the Kalman filter", Cambridge University Press.

Durbin and Koopman (2001), "Time series analysis by state space methods", Oxford University Press.

See Also

bsts, AddLocalLevel, AddLocalLinearTrend, AddGeneralizedLocalLinearTrend, SpikeSlabPrior, SdPrior, bsts.holdout.prediction.errors.

Examples

Run this code
data(AirPassengers)
  y <- log(AirPassengers)
  ss <- AddLocalLinearTrend(list(), y)
  ss <- AddSeasonal(ss, y, nseasons = 12)
  model <- bsts(y, state.specification = ss, niter = 500)
  errors <- bsts.prediction.errors(model, burn = 100)
  PlotDynamicDistribution(errors)

Run the code above in your browser using DataLab