Learn R Programming

statespacer (version 0.1.0)

StateSpaceEval: State Space Model Evaluation at Specified Parameters

Description

Evaluates the specified State Space model at the parameters specified by the user.

Usage

StateSpaceEval(
  param,
  y,
  H_format = NULL,
  local_level_ind = FALSE,
  slope_ind = FALSE,
  BSM_vec = NULL,
  cycle_ind = FALSE,
  addvar_list = NULL,
  level_addvar_list = NULL,
  arima_list = NULL,
  sarima_list = NULL,
  self_spec_list = NULL,
  exclude_level = NULL,
  exclude_slope = NULL,
  exclude_BSM_list = lapply(BSM_vec, FUN = function(x) 0),
  exclude_cycle_list = list(0),
  exclude_arima_list = lapply(arima_list, FUN = function(x) 0),
  exclude_sarima_list = lapply(sarima_list, FUN = function(x) 0),
  damping_factor_ind = rep(TRUE, length(exclude_cycle_list)),
  format_level = NULL,
  format_slope = NULL,
  format_BSM_list = lapply(BSM_vec, FUN = function(x) NULL),
  format_cycle_list = lapply(exclude_cycle_list, FUN = function(x) NULL),
  format_addvar = NULL,
  format_level_addvar = NULL,
  loglik_only = FALSE
)

Arguments

param

Parameters used to construct the system matrices.

y

N x p matrix containing the N observations of the p dependent variables.

H_format

Format of the H system matrix, the variance - covariance matrix of the observation equation.

local_level_ind

Boolean indicating whether a local level should be added to the state space model.

slope_ind

Boolean indicating whether a local level + slope should be added to the state space model.

BSM_vec

Vector containing the BSM seasonalities that have to be added to the state space model.

cycle_ind

Boolean indicating whether a cycle has to be added to the state space model.

addvar_list

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 N 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

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 N 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.

arima_list

Specifications of the ARIMA components, should be a list containing vectors of length 3 with the following format: c(AR, I, MA). Should be a list to allow different ARIMA models for different sets of dependent variables. Note: The AR and MA coefficients are constrained such that the AR component is stationary, and the MA component is invertible. See ansley1986note;textualstatespacer for details about the transformation used.

sarima_list

Specifications of the SARIMA components, should be a list containing lists that contain 4 named vectors. Vectors should be named: "s", "ar", "i", "ma". Should be a list of lists to allow different SARIMA models for different sets of dependent variables. Note: The AR and MA coefficients are constrained such that the AR components are stationary, and the MA components are invertible. See ansley1986note;textualstatespacer for details about the transformation used. Note: For multivariate models, the order of "s" matters, as matrix multiplication is not commutative!

self_spec_list

A list containing the specification of the self specified component. See the Details section of StateSpaceFit() for extensive details about the format that must be followed for this argument.

exclude_level

Vector containing the dependent variables that should not get a local level.

exclude_slope

Vector containing the dependent variables that should not get a slope.

exclude_BSM_list

List of vectors, each vector containing the dependent variables that should not get the corresponding BSM component.

exclude_cycle_list

The dependent variables that should not get the corresponding cycle component. Should be a list of vectors to allow different dependent variables to be excluded for different cycles.

exclude_arima_list

The dependent variables that should not be involved in the corresponding ARIMA component. Should be a list of vectors to allow different dependent variables to be excluded for different ARIMA components.

exclude_sarima_list

The dependent variables that should not be involved in the corresponding SARIMA component. Should be a list of vectors to allow different dependent variables to be excluded for different SARIMA components.

damping_factor_ind

Boolean indicating whether a damping factor should be included. Must be a vector if multiple cycles are included, to indicate which cycles should include a damping factor.

format_level

Format of the Q_level system matrix the variance - covariance matrix of the level state equation.

format_slope

Format of the Q_slope system matrix, the variance - covariance matrix of the slope state equation.

format_BSM_list

Format of the Q_BSM system matrix, the variance - covariance matrix of the BSM state equation. Should be a list to allow different formats for different seasonality periods.

format_cycle_list

Format of the Q_cycle system matrix, the variance - covariance matrix of the cycle state equation. Should be a list to allow different formats for different cycles.

format_addvar

Format of the Q_addvar system matrix, the variance - covariance matrix of the explanatory variables state equation.

format_level_addvar

Format of the Q_level_addvar system matrix, the variance - covariance matrix of the explanatory variables of the level state equation.

loglik_only

Boolean indicating whether only the loglikelihood should be returned.

Value

A list containing:

  • function_call: A list containing the input to the function.

  • system_matrices: A list containing the system matrices of the State Space model.

  • predicted: A list containing the predicted components of the State Space model.

  • filtered: A list containing the filtered components of the State Space model.

  • smoothed: A list containing the smoothed components of the State Space model.

  • diagnostics: A list containing items useful for diagnostical tests.

For extensive details about the object returned, see vignette("dictionary", package = "statespacer").

References

durbin2012timestatespacer

ansley1986notestatespacer

Examples

Run this code
# NOT RUN {
# Evaluates a local level model for the Nile data at given parameters
library(datasets)
y <- matrix(Nile)
eval <- StateSpaceEval(param = c(1, 1), y = y / 100, local_level_ind = TRUE)

# }

Run the code above in your browser using DataLab