add.local.linear.trend  R Documentation 
Add a local linear trend 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{N}(0, \sigma_\mu).
The equation for the slope is
\delta_{t+1} = \delta_t + \eta_t \qquad \eta_t \sim
\mathcal{N}(0, \sigma_\delta).
The prior distribution is on the level standard deviation
\sigma_\mu
and the slope standard deviation
\sigma_\delta
.
AddLocalLinearTrend(
state.specification = NULL,
y,
level.sigma.prior = NULL,
slope.sigma.prior = NULL,
initial.level.prior = NULL,
initial.slope.prior = NULL,
sdy,
initial.y)
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

slope.sigma.prior 
An object created by

initial.level.prior 
An object created by

initial.slope.prior 
An object created by

sdy 
The standard deviation of the series to be modeled. This
will be ignored if 
initial.y 
The initial value of the series being modeled. This will be
ignored if 
Returns a list with the elements necessary to specify a local linear trend state model.
Steven L. Scott steve.the.bayesian@gmail.com
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.
bsts
.
SdPrior
NormalPrior
data(AirPassengers)
y < log(AirPassengers)
ss < AddLocalLinearTrend(list(), y)
ss < AddSeasonal(ss, y, nseasons = 12)
model < bsts(y, state.specification = ss, niter = 500)
pred < predict(model, horizon = 12, burn = 100)
plot(pred)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.