Produces forecasts using a fitted State Space Model.
StateSpaceForecast( fit, addvar_list_fc = NULL, level_addvar_list_fc = NULL, self_spec_list_fc = NULL, forecast_period = 1 )
| fit | A list containing the specifications of the State Space Model, 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. |
A list containing the forecasts and corresponding uncertainties. In addition, it returns the components of the forecasts, as specified by the State Space model.
Durbin J, Koopman SJ (2012). Time series analysis by state space methods. Oxford university press.
# 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)#> Warning: Number of initial parameters is less than the required amount of parameters (2), recycling the initial parameters the required amount of times.#>#> Parameter scaling:[1] 1 1 #> initial value 2.443183 #> iter 10 value 1.775548 #> final value 1.775527 #> converged#>#># 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')