Description Usage Arguments Value Author(s) References See Also Examples
Add a seasonal model to a state specification.
The seasonal model can be thought of as a regression on
nseasons
dummy variables with coefficients constrained to sum
to 1 (in expectation). If there are S
seasons then the state
vector gamma is of dimension S-1
. The first
element of the state vector obeys
gamma[t+1, 1] = -1 * sum(gamma[t, -1]) + rnorm(1, 0, sigma)
1 2 3 4 5 6 7 8 | AddSeasonal(
state.specification,
y,
nseasons,
season.duration = 1,
sigma.prior,
initial.state.prior,
sdy)
|
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. |
nseasons |
The number of seasons to be modeled. |
season.duration |
The number of time periods in each season. |
sigma.prior |
An object created by |
initial.state.prior |
An object created using
|
sdy |
The standard deviation of the series to be modeled. This
will be ignored if |
Returns a list with the elements necessary to specify a seasonal 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.
1 2 3 4 5 6 7 | 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.