predict.statespacer {statespacer} | R Documentation |
State Space Model Forecasting
Description
Produces forecasts and out of sample simulations using a fitted State Space Model.
Usage
## S3 method for class 'statespacer'
predict(
object,
addvar_list_fc = NULL,
level_addvar_list_fc = NULL,
self_spec_list_fc = NULL,
forecast_period = 1,
nsim = 0,
...
)
Arguments
object |
A statespacer object as returned by |
addvar_list_fc |
A list containing the explanatory variables for each
of the dependent variables. The list should contain p (number of dependent
variables) elements. Each element of the list should be a
|
level_addvar_list_fc |
A list containing the explanatory variables
for each of the dependent variables. The list should contain p
(number of dependent variables) elements. Each element of the list should
be a |
self_spec_list_fc |
A list containing the specification of the self
specified component. Does not have to be specified if it does not differ
from |
forecast_period |
Number of time steps to forecast ahead. |
nsim |
Number of simulations to generate over the forecast period. |
... |
Arguments passed on to the |
Value
A list containing the forecasts and corresponding uncertainties. In addition, it returns the components of the forecasts, as specified by the State Space model.
Author(s)
Dylan Beijers, dylanbeijers@gmail.com
References
Durbin J, Koopman SJ (2012). Time series analysis by state space methods. Oxford university press.
Examples
# Fit a SARIMA model on the AirPassengers data
library(datasets)
Data <- matrix(log(AirPassengers))
sarima_list <- list(list(s = c(12, 1), ar = c(0, 0), i = c(1, 1), ma = c(1, 1)))
fit <- statespacer(y = Data,
H_format = matrix(0),
sarima_list = sarima_list,
initial = c(0.5*log(var(diff(Data))), 0, 0))
# Obtain forecasts for 100 steps ahead using the fitted model
fc <- predict(fit, forecast_period = 100, nsim = 10)
# Plot the forecasts and one of the simulation paths
plot(fc$y_fc, type = 'l')
lines(fc$sim$y[, 1, 1], type = 'p')