Learn R Programming

KFAS (version 1.2.5)

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 = 50, convtol = 1e-08)

Arguments

model
Object of class SSModel.
filtering
Types of filtering. Possible choices are "state", "signal", "mean", and "none". Default is "state" for Gaussian and "none" for non-Gaussian models. Multiple values are allowed. For Gaussian models, the signal is the mean. Note that filtering for non-Gaussian models with importance sampling can be very slow with large models.
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 "signal". Multiple values are allowed.
simplify
If FALSE and the 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 used in importance sampling. Only used for non-Gaussian models. Default is 0, which computes the approximating Gaussian model by approxSSM and performs the usual Gaussian filtering/smoothing so that the smoothed state estimates equals to the conditional mode of $p(\alpha[t]|y)$. In case of nsim = 0, the mean estimates and their variances are computed using the Delta method (ignoring the covariance terms).
theta
Initial values for conditional mode theta. Only used for non-Gaussian models.
maxiter
The maximum number of iterations used in Gaussian approximation. Default is 50. Only used for non-Gaussian models.
convtol
Tolerance parameter for convergence checks for Gaussian approximation. Only used for non-Gaussian models.

Value

What KFS returns depends on the arguments filtering, smoothing and simplify, and whether the model is Gaussian or not:In addition, if argument simplify = FALSE, list contains following components:

Details

Notice that in case of multivariate Gaussian 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 the prediction error $v[t]$ are uncorrelated, and F, Finf, K and Kinf contain only the diagonal elemens of the corresponding covariance matrices. The usual multivariate versions of F and v can be obtained from the output of KFS using the function mvInnovations.

In rare cases of a diffuse initialization phase with highly correlated states, cumulative rounding errors in computing Finf and Pinf can sometimes cause the diffuse phase end too early, or the backward smoothing gives negative variances. Changing the tolerance parameter tol of the model (see SSModel) to smaller (or larger) can sometimes help. Another option is to redefine the prior state variances more informative.

Fon non-Gaussian models the components corresponding to diffuse filtering (Finf, Pinf, d, Kinf) are not returned even when filtering is used. Results based on approximating Gaussian model can be obtained by running KFS using the output of approxSSM.

In case of non-Gaussian models with nsim = 0, the smoothed estimates relate to the conditional mode of $p(\alpha|y)$. When using importance sampling (nsim>0), results correspond to the conditional mean of $p(\alpha|y)$.

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.