Learn R Programming

bsts (version 0.9.10)

predict.mbsts: Prediction for Multivariate Bayesian Structural Time Series

Description

Generate draws from the posterior predictive distribution of an mbsts object.

Usage

# S3 method for mbsts
predict(object,
        horizon = 1,
        newdata = NULL,
        timestamps = NULL,
        burn = SuggestBurn(.1, object),
        na.action = na.exclude,
        quantiles = c(.025, .975),
        seed = NULL,
        ...)

Value

Returns an object of class mbsts.prediction, which is a list.

Arguments

object

An object of class mbsts.

horizon

An integer specifying the number of periods into the future you wish to predict. If object contains a regression component then the forecast horizon is nrow(newdata) and this argument is not used.

newdata

A vector, matrix, or data frame containing the predictor variables to use in making the prediction. This is only required if object contains a regression component. If a data frame, it must include variables with the same names as the data used to fit object. The first observation in newdata is assumed to be one time unit after the end of the last data used in fitting object, and the subsequent observations are sequential time points. If the regression part of object contains only a single predictor then newdata can be a vector. If newdata is passed as a matrix it is the caller's responsibility to ensure that it contains the correct number of columns and that the columns correspond to those in object$coefficients.

timestamps

A vector of time stamps (of the same type as the timestamps used to fit object), with one per row of newdata (or element of newdata, if newdata is a vector). The time stamps give the time points as which each prediction is desired. They must be interpretable as integer (0 or larger) time steps following the last time stamp in object. If NULL, then the requested predictions are interpreted as being at 1, 2, 3, ... steps following the training data.

burn

An integer describing the number of MCMC iterations in object to be discarded as burn-in. If burn <= 0 then no burn-in period will be discarded.

na.action

A function determining what should be done with missing values in newdata.

quantiles

A numeric vector of length 2 giving the lower and upper quantiles to use for the forecast interval estimate.

seed

An integer to use as the C++ random seed. If NULL then the C++ seed will be set using the clock.

...

Not used. Present to match the signature of the default predict method.

Author

Steven L. Scott

Details

The prediction is based off of samples taken from the posterior distribution of a multivariate Bayesian structural time series model.

As an added convenience, means and interval estimates are produced from the posterior predictive distribution.

See Also

mbsts. predict.bsts plot.mbsts.prediction