Learn R Programming

KFAS (version 1.0.3)

KFS: Kalman Filter and Smoother with Exact Diffuse Initialization for Exponential Family State Space Models

Description

Performs Kalman filtering and smoothing with exact diffuse initialization using univariate approach for exponential family state space models.

Usage

KFS(model, filtering, smoothing, simplify = TRUE, transform = c("ldl",
  "augment"), nsim = 0, theta, maxiter = 25)

Arguments

model
Object of class SSModel.
filtering
Types of filtering. Possible choices are 'state', 'signal', 'mean', and 'none'. Default is 'none'. Multiple values are allowed. Note that for Gaussian models, signal is mean. Note that filtering for non-Gaussian models with importance sampling
smoothing
Types of smoothing. Possible choices are 'state', 'signal', 'mean', 'disturbance' and 'none'. Default is 'state' and 'mean'. For non-Gaussian models, option 'disturbance' is not supported, and for Gaussian models option 'mean' is identical to
simplify
If FALSE and model is completely Gaussian, KFS returns some generally not so interesting variables from filtering and smoothing. Default is TRUE.
transform
How to transform the model in case of non-diagonal covariance matrix $H$. Defaults to 'ldl'. See function transformSSM for details.
nsim
The number of independent samples. Only used for non-Gaussian model. Default is 0, which computes the approximating Gaussian model by approxSSM and performs the usual Gaussian smoothing so that
theta
Initial values for conditional mode theta. Only used for non-Gaussian model.
maxiter
The maximum number of iterations used in linearisation. Default is 25. Only used for non-Gaussian model.

Value

  • What KFS returns depends on the arguments filtering, smoothed and simplify, and whether the model is Gaussian or not:
  • modelOriginal state space model.
  • KFS_transformType of H after possible transformation.
  • logLikValue of the log-likelihood function. Only computed for Gaussian models.
  • aOne step predictions of states, $a_t=E(\alpha_t | y_{t-1}, \ldots , y_{1})$.
  • PCovariance matrices (of the non-diffuse parts) of predicted states, $P_t=Cov(\alpha_t | y_{t-1}, \ldots , y_{1})$.
  • PinfDiffuse part of $P_t$. Only returned for Gaussian models.
  • tFiltered estimates of signals, $E(Z_t\alpha_t | y_{t-1}, \ldots , y_{1})$.
  • P_thetaCovariances $Var(Z[t]\alpha_t | y_{t-1}, \ldots , y_{1}).$.
  • mFiltered estimates of $f(\theta_t) | y_{t-1}, \ldots , y_{1})$, where $f$ is the inverse link function.
  • P_muCovariances $Cov(f(\theta_t)| y_{t-1}, \ldots , y_{1})$. If nsim=0, only diagonal elements (variances) are computed, using the delta method.
  • alphahatSmoothed estimates of states, $E(\alpha_t | y_1, \ldots , y_n)$.
  • VCovariances $Var(\alpha_t | y_1, \ldots , y_n)$.
  • thetahatSmoothed estimates of signals, $E(Z_t\alpha_t | y_1, \ldots , y_n)$.
  • V_thetaCovariances $Var(Z[t]\alpha_t | y_1, \ldots , y_n).$.
  • muhatSmoothed estimates of $f(\theta_t) | y_1, \ldots , y_n)$, where $f$ is the inverse link function.
  • V_muCovariances $Cov(f(\theta_t)| y_1, \ldots , y_n)$. If nsim=0, only diagonal elements (variances) are computed, using the delta method.
  • etahatSmoothed disturbance terms $E(\eta_t | y_1, \ldots , y_n)$.
  • V_etaCovariances $Var(\eta_t | y_1, \ldots , y_n)$.
  • epshatSmoothed disturbance terms $E(\epsilon_{t,i} | y_1, \ldots , y_n)$. Note that due to the possible diagonalization these are on transformed scale.
  • V_epsDiagonal elements of $Var(\epsilon_{t} | y_1, \ldots , y_n)$. Note that due to the diagonalization the off-diagonal elements are zero.
  • iterationsThe number of iterations used in linearization of non-Gaussian model.
  • vPrediction errors $v_{t,i} = y_{t,i} - Z_{i,t}a_{t,i}, i=1,\ldots,p$, where $a_{t,i}=E(\alpha_t | y_{t,i-1}, \ldots, y_{t,1}, \ldots , y_{1,1})$. Only returned for Gaussian models.
  • FPrediction error variances $Var(v_{t,i})$. Only returned for Gaussian models.
  • FinfDiffuse part of $F_t$. Only returned for Gaussian models.
  • dThe last index of diffuse phase, i.e. the non-diffuse phase began from time $d+1$. Only returned for Gaussian models.
  • jThe index of last $y_{i,t}$ of diffuse phase. Only returned for Gaussian models.
  • In addition, if argument simplify=FALSE, list contains following components:
  • KCovariances $Cov(\alpha_{t,i}, y_{t,i} | y_{t,i-1}, \ldots, y_{t,1}, y_{t-1}, \ldots , y_{1}), \quad i=1,\ldots,p$.
  • KinfDiffuse part of $K_t$.
  • rWeighted sums of innovations $v_{t+1}, \ldots , v_{n}$. Notice that in literature t in $r_t$ goes from $0, \ldots, n$. Here $t=1, \ldots, n+1$. Same applies to all r and N variables.
  • r0, r1Diffuse phase decomposition of $r_t$.
  • NCovariances $Var(r_t)$ .
  • N0, N1, N2Diffuse phase decomposition of $N_t$.

Details

Notice that in case of multivariate observations, v, F, Finf, K and Kinf are usually not the same as those calculated in usual multivariate Kalman filter. As filtering is done one observation element at the time, the elements of prediction error $v_t$ are uncorrelated, and F, Finf, K and Kinf contain only the diagonal elemens of the corresponding covariance matrices. In rare cases of a very long diffuse initialization phase with highly correlated states, cumulative rounding errors in computing Finf and Pinf can sometimes cause the diffuse phase end too early. Changing the tolerance parameter tol of the model (see SSModel) to smaller (or larger) should help. In case of non-Gaussian models with nsim=0, the smoothed estimates relate the conditional mode of $p(\alpha|y)$, and are equivalent with the results from generalized linear models. When using importance sampling (nsim>0), results correspond to the conditional mean.

References

Koopman, S.J. and Durbin J. (2000). Fast filtering and smoothing for non-stationary time series models, Journal of American Statistical Assosiation, 92, 1630-38. Koopman, S.J. and Durbin J. (2001). Time Series Analysis by State Space Methods. Oxford: Oxford University Press. Koopman, S.J. and Durbin J. (2003). Filtering and smoothing of state vector for diffuse state space models, Journal of Time Series Analysis, Vol. 24, No. 1.