KFAS (version 1.3.7)

rstandard.KFS: Extract Standardized Residuals from KFS output

Description

Extract Standardized Residuals from KFS output

Usage

# S3 method for KFS
rstandard(model, type = c("recursive", "pearson", "state"),
  standardization_type = c("marginal", "cholesky"), zerotol = 0, ...)

Arguments

model

KFS object

type

Type of residuals. See details.

standardization_type

Type of standardization. Either "marginal" (default) for marginal standardization or "cholesky" for Cholesky-type standardization.

zerotol

Tolerance parameter for positivity checking in standardization. Default is zero. The values of D <= zerotol * max(D, 0) are deemed to zero.

...

Ignored.

Details

For object of class KFS with fully Gaussian observations, several types of standardized residuals can be computed. Also the standardization for multivariate residuals can be done either by Cholesky decomposition \(L^{-1}_t residual_t,\) or component-wise \(residual_t/sd(residual_t),\).

  • "recursive": For Gaussian models the vector standardized one-step-ahead prediction residuals are defined as $$v_{t,i}/\sqrt{F_{i,t}},$$ with residuals being undefined in diffuse phase. Note that even in multivariate case these standardized residuals coincide with the ones obtained from the Kalman filter without the sequential processing (which is not true for the non-standardized innovations). For non-Gaussian models the vector standardized recursive residuals are obtained as $$L^{-1}_t (y_{t}-\mu_{t}),$$ where \(L_t\) is the lower triangular matrix from Cholesky decomposition of \(Var(y_t|y_{t-1},\ldots,y_1)\). Computing these for large non-Gaussian models can be time consuming as filtering is needed.

    For Gaussian models the component-wise standardized one-step-ahead prediction residuals are defined as $$v_{t}/\sqrt{diag(F_{t})},$$ where \(v_{t}\) and \(F_{t}\) are based on the standard multivariate processing. For non-Gaussian models these are obtained as $$(y_{t}-\mu_{t})/\sqrt{diag(F_t)},$$ where \(F_t=Var(y_t|y_{t-1},\ldots,y_1)\).

  • "state": Residuals based on the smoothed state disturbance terms \(\eta\) are defined as $$L^{-1}_t \hat \eta_t, \quad t=1,\ldots,n,$$ where \(L_t\) is either the lower triangular matrix from Cholesky decomposition of \(Q_t - V_{\eta,t}\), or the diagonal of the same matrix.

  • "pearson": Standardized Pearson residuals $$L^{-1}_t(y_{t}-\theta_{i}), \quad t=1,\ldots,n,$$ where \(L_t\) is the lower triangular matrix from Cholesky decomposition of \(Var(y_t|y_{n},\ldots,y_1)\), or the diagonal of the same matrix. For Gaussian models, these coincide with the standardized smoothed \(\epsilon\) disturbance residuals, and for generalized linear models these coincide with the standardized Pearson residuals (hence the name).

Examples

Run this code
# NOT RUN {
modelNile <- SSModel(Nile ~ SSMtrend(1, Q = list(matrix(NA))), H = matrix(NA))
modelNile <- fitSSM(inits = c(log(var(Nile)),log(var(Nile))), model = modelNile,
  method = "BFGS")$model
# Filtering and state smoothing
out <- KFS(modelNile, smoothing = c("state", "mean", "disturbance"))

plot(cbind(
    recursive = rstandard(out),
    irregular = rstandard(out, "pearson"),
    state = rstandard(out, "state")),
  main = "recursive and auxiliary residuals")
# }

Run the code above in your browser using DataLab