Produces forecasts and out of sample simulations using a fitted State Space Model.

# S3 method for 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 statespacer.

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 forecast_period x k_p matrix, with k_p being the number of explanatory variables for the pth dependent variable. If no explanatory variables should be added for one of the dependent variables, then set the corresponding element to NULL.

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 forecast_period x k_p matrix, with k_p being the number of explanatory variables for the pth dependent variable. If no explanatory variables should be added for one of the dependent variables, then set the corresponding element to NULL.

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 self_spec_list as passed on to statespacer. If some system matrices are time-varying then you should specify this argument. See statespacer for details about the format that must be followed for this argument.

forecast_period

Number of time steps to forecast ahead.

nsim

Number of simulations to generate over the forecast period.

...

Arguments passed on to the predict generic. Should not be used!

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.

References

Durbin J, Koopman SJ (2012). Time series analysis by state space methods. Oxford university press.

Author

Dylan Beijers, dylanbeijers@gmail.com

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')