Learn R Programming

bsts (version 0.6.1)

add.generalized.local.linear.trend: A generalized local linear trend state component

Description

The generalized local linear trend model is more complicated. It assumes the level moves according to a random walk, but the slope moves according to an AR1 process centered on some potentially nonzero value $D$. The equation for the mean is

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

The equation for the slope is $$\delta_{t+1} = D + \phi (\delta_t - D) + \eta_t \qquad \eta_t \sim \mathcal{N(0, \sigma_\delta)}.$$

The prior distribution for this model has four independent components. There is an inverse gamma prior on the level standard deviation $\sigma_\mu$, an inverse gamma prior on the slope standard deviation $\sigma_\delta$, a Gaussian prior on the long run slope parameter $D$, and a potentially truncated Gaussian prior on the AR1 coefficient $\phi$. If the prior on $\phi$ is truncated to (-1, 1), then the slope will exhibit short term stationary variation around the long run slope $D$.

Usage

AddGeneralizedLocalLinearTrend(
     state.specification,
     y,
     level.sigma.prior,
     slope.mean.prior,
     slope.ar1.prior,
     slope.sigma.prior,
     initial.level.prior,
     initial.slope.prior,
     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.
level.sigma.prior
An object created by SdPrior describing the prior distribution for the standard deviation of the level component.
slope.mean.prior
An object created by NormalPrior giving the prior distribution for the mean parameter in the generalized local linear trend model (see below).
slope.ar1.prior
An object created by Ar1CoefficientPrior giving the prior distribution for the ar1 coefficient parameter in the generalized local linear trend model (see below).
slope.sigma.prior
An object created by SdPrior describing the prior distribution of the standard deviation of 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 generalized local linear trend state model.

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