Learn R Programming

KFAS (version 0.9.9)

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. For non-Gaussian models, state smoothing is provided with additional smoothed mean and variance of observations.

Usage

KFS(object,
    smoothing = c("state", "disturbance", "both", "none"),
    simplify = TRUE, transform = c("ldl", "augment"),
    nsim = 100, theta = NULL, maxiter = 100)

Arguments

object
Object of class SSModel or KFS (in which case only smoothing is performed).
smoothing
Perform state or disturbance smoothing or both. Default is "state" for Gaussian models. For non-Gaussian models, state smoothing is always performed.
simplify
If FALSE, 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
Number of independent samples. Default is 100. Only used for non-Gaussian model.
theta
Initial values for conditional mode theta. Default is log(mean(y/u)) for Poisson and log(mean(y/(u-y))) for Binomial distribution (or log(mean(y)) in case of $u_t-y_t = 0$ for some $t$). Only used for non-G
maxiter
Maximum number of iterations used in linearisation. Default is 100. Only used for non-Gaussian model.

Value

  • For Gaussian model, a list with the following components:
  • modelOriginal state space model.
  • KFS.transformType of H after possible transformation.
  • logLikValue of the log-likelihood function.
  • aOne step predictions of states, $a_t=E(\alpha_t | y_{t-1}, \ldots , y_{1})$.
  • PCovariance matrices of predicted states, $P_t=Cov(\alpha_t | y_{t-1}, \ldots , y_{1})$.
  • PinfDiffuse part of $P_t$.
  • vPrediction errors $v_{i,t} = y_{i,t} - Z_{i,t}a_{i,t},\quad i=1,\ldots,p$, \ where $a_{i,t}=E(\alpha_t | y_{i-1,t}, \ldots, y_{1,t}, y_{t-1}, \ldots , y_{1})$.
  • FPrediction error variances $Var(v_t)$.
  • FinfDiffuse part of $F_t$.
  • dThe last index of diffuse phase, i.e. the non-diffuse phase began from time $d+1$.
  • jThe index of last $y_{i,t}$ of diffuse phase.
  • alphahatSmoothed estimates of states, $E(\alpha_t | y_1, \ldots , y_n)$. Only computed if smooth="state" or smooth="both".
  • VCovariances $Var(\alpha_t | y_1, \ldots , y_n).$ Only computed if smooth="state" or smooth="both".
  • etahatSmoothed disturbance terms $E(\eta_t | y_1, \ldots , y_n)$.Only computed if smooth="disturbance" or smooth="both".
  • V_etaCovariances $Var(\eta_t | y_1, \ldots , y_n)$. Only computed if smooth="disturbance" or smooth="both".
  • epshatSmoothed disturbance terms $E(\epsilon_{t} | y_1, \ldots , y_n)$. Only computed if smooth="disturbance" or smooth="both".
  • V_epsDiagonal elements of $Var(\epsilon_{t} | y_1, \ldots , y_n)$. Note that due to the diagonalization, off-diagonal elements are zero. Only computed if smooth="disturbance" or smooth="both".
  • In addition, if argument simplify=FALSE, list contains following components:
  • KCovariances $Cov(\alpha_{t,i}, y_{t,i} | y_{i-1,t}, \ldots, y_{1,t}, 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$.
  • For non-Gaussian model, a list with the following components:
  • modelOriginal state space model with additional elements from function approxSSM.
  • alphahatSmoothed estimates of states $E(\alpha_t | y_1, \ldots , y_n)$.
  • VCovariances $Var(\alpha_t | y_1, \ldots , y_n)$.
  • yhatA time series object containing smoothed means of observation distributions, with parameter $u_texp(\hat\theta_t)$ for Poisson and $u_texp(\hat\theta_t)/(1+exp(\hat\theta_t))$.
  • V.yhata vector of length containing smoothed variances of observation distributions.

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 tolF to smaller (or larger) should help.

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.