Learn R Programming

statespacer (version 0.1.0)

StateSpaceForecast: State Space Model Forecasting

Description

Produces forecasts using a fitted State Space Model.

Usage

StateSpaceForecast(
  fit,
  addvar_list_fc = NULL,
  level_addvar_list_fc = NULL,
  self_spec_list_fc = NULL,
  forecast_period = 1
)

Arguments

fit

A list containing the specifications of the State Space Model, as returned by StateSpaceFit or StateSpaceEval.

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 StateSpaceFit() or StateSpaceEval(). If some system matrices are time-varying then you should specify this argument. See StateSpaceFit() for details about the format that must be followed for this argument.

forecast_period

Number of time steps to forecast ahead.

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

durbin2012timestatespacer

Examples

Run this code
# NOT RUN {
# Fits a local level model for the Nile data
library(datasets)
y <- matrix(Nile)
fit <- StateSpaceFit(initial = 1, y = y / 100, local_level_ind = TRUE)

# Obtain forecasts for 10 steps ahead using the fitted model
fc <- StateSpaceForecast(fit, forecast_period = 10)

# Plot the forecasts
plot(1:10, fc$y_fc * 100, type = 'l')

# }

Run the code above in your browser using DataLab