add.shared.local.level {bsts}R Documentation

Local level trend state component

Description

Add a shared local level model to a state specification. The shared local level model assumes the trend is a multivariate random walk:

alpha[t+1, ] = alpha[t, ] + rnorm(nfactors, 0, sigma).

The contribution to the mean of the observed series obeys

y[t, ] = B %*% alpha[t, ]

plus observation error. Identifiability constraints ipmly that the observation coefficients B form a rectangular lower triangular matrix with diagonal 1.0.

Usage

  AddSharedLocalLevel(
     state.specification,
     response,
     nfactors, 
     coefficient.prior = NULL,
     initial.state.prior = NULL,
     timestamps = NULL,
     series.id = NULL,
     sdy,
     ...)

Arguments

state.specification

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

response

The time series to be modeled. This can either be a matrix with rows as time and columns as series, or it can be a numeric vector. If a vector is passed then timestamps and series.id are required. Otherwise they are unused.

nfactors

The number of latent factors to include in the model. This is the dimension of the state for this model component.

coefficient.prior

Prior distribution on the observation coefficients. This currently must be a ScaledMatrixNormalPrior. Expect other choices in the future.

initial.state.prior

An object of class MvnPrior, describing the prior distribution of the initial state vector (at time 1).

timestamps

If response is in long format (i.e. a vector instead of a matrix) this argument is a vector of the same length indicating the time index to which each element of response belongs.

series.id

If response is in long format (i.e. a vector instead of a matrix) this argument is a vector of the same length indicating the time series to which each element of response belongs.

sdy

A vector giving the standard deviation of each series to be modeled. This argument is only necessary if response cannot be supplied directly.

...

Extra arguments passed to ConditionalZellnerPrior, used to create a default prior for the observation coefficients when coefficient.prior is left as NULL.

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


[Package bsts version 0.9.6 Index]