add.student.local.linear.trend {bsts}R Documentation

Robust local linear trend

Description

Add a local level model to a state specification. The local linear trend model assumes that both the mean and the slope of the trend follow random walks. The equation for the mean is

\mu_{t+1} = \mu_t + \delta_t + \epsilon_t \qquad \epsilon_t \sim \mathcal{T}_{\nu_\mu}(0, \sigma_\mu).

The equation for the slope is

\delta_{t+1} = \delta_t + \eta_t \qquad \eta_t \sim \mathcal{T}_{\nu_\delta}(0, \sigma_\delta).

Independent prior distributions are assumed on the level standard deviation, \sigma_\mu the slope standard deviation \sigma_\delta, the level tail thickness \nu_\mu, and the slope tail thickness \nu_\delta.

Usage

  AddStudentLocalLinearTrend(
     state.specification = NULL,
     y,
     save.weights = FALSE,
     level.sigma.prior = NULL,
     level.nu.prior = NULL,
     slope.sigma.prior = NULL,
     slope.nu.prior = NULL,
     initial.level.prior = NULL,
     initial.slope.prior = NULL,
     sdy,
     initial.y)

Arguments

state.specification

A list of state components that you wish to add to. If omitted, an empty list will be assumed.

y

The time series to be modeled, as a numeric vector.

save.weights

A logical value indicating whether to save the draws of the weights from the normal mixture representation.

level.sigma.prior

An object created by SdPrior describing the prior distribution for the standard deviation of the level component.

level.nu.prior

An object inheritng from the class DoubleModel, representing the prior distribution on the nu tail thickness parameter of the T distribution for errors in the evolution equation for the level component.

slope.sigma.prior

An object created by SdPrior describing the prior distribution of the standard deviation of the slope component.

slope.nu.prior

An object inheritng from the class DoubleModel, representing the prior distribution on the nu tail thickness parameter of the T distribution for errors in the evolution equation for the slope component.

initial.level.prior

An object created by NormalPrior describing the initial distribution of the level portion of the initial state vector.

initial.slope.prior

An object created by NormalPrior describing the prior distribution for the slope portion of the initial state vector.

sdy

The standard deviation of the series to be modeled. This will be ignored if y is provided, or if all the required prior distributions are supplied directly.

initial.y

The initial value of the series being modeled. This will be ignored if y is provided, or if the priors for the initial state are all provided directly.

Value

Returns a list with the elements necessary to specify a local linear trend state model.

Author(s)

Steven L. Scott steve.the.bayesian@gmail.com

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. SdPrior NormalPrior

Examples

  data(rsxfs)
  ss <- AddStudentLocalLinearTrend(list(), rsxfs)
  model <- bsts(rsxfs, state.specification = ss, niter = 500)
  pred <- predict(model, horizon = 12, burn = 100)
  plot(pred)

[Package bsts version 0.9.10 Index]