Learn R Programming

KFAS (version 1.0.3)

SSMarima: Create a State Space Model Object of Class SSModel

Description

Function SSModel creates a state space object object of class SSModel which can be used as an input object for various functions of KFAS package.

Usage

SSMarima(ar = NULL, ma = NULL, d = 0, Q, stationary = TRUE, index, n,
  ynames)

SSMcustom(Z, T, R, Q, a1, P1, P1inf, index, n)

SSMcycle(period, type, Q, index, a1, P1, P1inf, n, ynames)

SSModel(formula, data, H, u, distribution, tol = .Machine$double.eps^0.5)

SSMregression(rformula, data, type, Q, index, R, a1, P1, P1inf, n, ynames)

SSMseasonal(period, sea.type = c("dummy", "trigonometric"), type, Q, index,
  a1, P1, P1inf, n, ynames)

SSMtrend(degree = 1, type, Q, index, a1, P1, P1inf, n, ynames)

Arguments

formula
an object of class formula containing the symbolic description of the model. The intercept term can be removed with -1 as in lm. In case of trend or differenced arima c
data
an optional data frame, list or environment containing the variables in the model.
H
covariance matrix or array of disturbance terms $\epsilon_t$ of observation equation. Omitted in case of non-gaussian distributions. Augment the state vector if you want to add additional noise.
u
additional parameters for non-gaussian models. See details in KFAS.
distribution
a vector of distributions of the observations. Default is rep('gaussian',p).
tol
a tolerance parameter for a diffuse phase. Smallest value of Finf not counted for zero. Defaults to .Machine$double.eps^0.5.
index
a vector indicating for which series the corresponding components are constructed.
type
for cycle, seasonal, trend and regression components, character string defining if 'distinct' or 'common' states are used for different series.
Q
for arima, cycle and seasonal component, a $p \times p$ covariance matrix of the disturbances (or in the time varying case $p \times p \times n$ array), where where p=length(index). For trend component, list of length de
a1
optional $m \times 1$ matrix giving the expected value of the initial state vector $\alpha_1$.
P1
optional $m \times m$ matrix giving the covariance matrix of $\alpha_1$. In the diffuse case the non-diffuse part of $P_1$.
P1inf
optional $m \times m$ matrix giving the diffuse part of $P_1$. Diagonal matrix with ones on diagonal elements which correspond to the unknown initial states.
R
for a custom and regression components, optional $m \times k$ system matrix or array of transition equation.
ar
for arima component, a numeric vector containing the autoregressive coeffients.
ma
for arima component, a numericvector containing the moving average coeffients.
d
for arima component, a degree of differencing.
stationary
for arima component, logical value indicating whether a stationarity of the arima part is assumed. Defaults to TRUE.
Z
for a custom component, system matrix or array of observation equation.
T
for a custom component, system matrix or array of transition equation.
period
for a cycle and seasonal components, the length of the cycle/seasonal pattern.
sea.type
for seasonal component, character string defining whether to use 'dummy' or 'trigonometric' form of the seasonal component.
degree
for trend component, integer defining the degree of the polynomial trend. 1 corresponds to local level, 2 for local linear trend and so forth.
rformula
for regression component, right hand side formula or list of of such formulas defining the custom regression part.
n
length of the series, only used internally for dimensionality check.
ynames
names of the times series, only used internally.

Value

  • object of class SSModel, which is a list with the following components:
  • yA n x p matrix containing the observations.
  • ZA p x m x 1 or p x m x n array corresponding to the system matrix of observation equation.
  • HA p x p x 1 or p x p x n array corresponding to the covariance matrix of observational disturbances epsilon.
  • TA m x m x 1 or m x m x n array corresponding to the first system matrix of state equation.
  • RA m x k x 1 or m x k x n array corresponding to the second system matrix of state equation.
  • QA k x k x 1 or k x k x n array corresponding to the covariance matrix of state disturbances eta
  • a1A m x 1 matrix containing the expected values of the initial states.
  • P1A m x m matrix containing the covariance matrix of the nondiffuse part of the initial state vector.
  • P1infA m x m matrix containing the covariance matrix of the diffuse part of the initial state vector.
  • uA n x p matrix of an additional parameters in case of non-Gaussian model.
  • distributionA vector of length p giving the distributions of the observations.
  • tolA tolerance parameter for the diffuse phase.
  • callOriginal call to the function.
  • In addition, object of class SSModel contains following attributes:
  • namesNames of the list components.
  • p, m, k, nInteger valued scalars defining the dimensions of the model components.
  • state_typesTypes of the states in the model.

Details

Formula of the model can contain the usual regression part and additional functions defining different types of components of the model, named as SSMarima, SSMcustom, SSMcycle, SSMregression, SSMseasonal and SSMtrend.

See Also

KFAS for examples.

Examples

Run this code
examplemodel<-SSModel(cbind(y1,y2,y3)  ~ x1+x2
+ SSMregression(~-1+x3+x4,data=dataset,type='common',index=c(1,3),Q=diag(c(0.05,0.1)))
+ SSMtrend(degree=1,index=1,Q=list(matrix(0.2)))
+ SSMtrend(degree=2,index=2:3,Q=list(matrix(c(0.2,0.1,0.1,0.2),2,2),diag(0.07,2)))
+ SSMcycle(period=25,Q=matrix(c(0.3,0.2,0.1,0.2,0.4,0.05,0.1,0.05,0.1),3,3))
, data=dataset, H=matrix(c(1,0.7,0.7,0.7,1,0.7,0.7,0.7,1),3,3))

Run the code above in your browser using DataLab