## S3 method for class 'KFS'
rstandard(model, type = c("recursive", "pearson", "state"),
standardization_type = c("marginal", "cholesky"), ...)
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.
...
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]/√{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]-μ[t]),
where
L[t] is the lower triangular matrix from Cholesky decomposition
of Var(y[t]|y[t-1],…,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])/√{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]-μ[t])/√{diag(F[t])},
where
F[t]=Var(y[t]|y[t-1],…,y[1]).
"state": Residuals based on the smoothed state disturbance terms
η are defined as
L^{-1}[t] hat η[t], t=1,…,n,
where L[t] is
either the lower triangular matrix from Cholesky decomposition of
Q[t] - V[η,t], or the diagonal of the same matrix.
"pearson": Standardized Pearson residuals
L^(-1)[t](y[t]-θ[t]), t=1,…,n,
where
L[t] is the lower triangular matrix from Cholesky decomposition
of Var(y[t]|y[n],…,y[1]), or the diagonal of the same
matrix. For Gaussian models, these coincide with the standardized smoothed
ε disturbance residuals, and for generalized linear models
these coincide with the standardized Pearson residuals (hence the name).
'deviance': Deviance residuals. Deprecated. This option was meant to be
used only for the GLM comparisons, as their generalization to other models is
lacking, but these will be completely removed in future in order to avoid
misleading results in non-GLM settings.
Examples
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")
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(KFAS)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/KFAS/rstandard.KFS.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rstandard.KFS
> ### Title: Extract Standardized Residuals from KFS output
> ### Aliases: rstandard.KFS
>
> ### ** Examples
>
> 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")
>
>
>
>
>
> dev.off()
null device
1
>