Learn R Programming

KFAS (version 1.5.1)

hatvalues.KFS: Extract Hat Values from KFS Output

Description

Extract hat values from KFS output, when KFS was run with signal (non-Gaussian case) or mean smoothing (Gaussian case).

Usage

# S3 method for KFS
hatvalues(model, ...)

Value

Multivariate time series containing hat values.

Arguments

model

An object of class KFS.

...

Additional arguments to approxSSM.

Details

Hat values in KFAS are defined as the diagonal elements of V_t/H_t where V_t is the covariance matrix of signal/mean at time t and H_t is the covariance matrix of disturbance vector \(\epsilon\) of (approximating) Gaussian model at time t. This definition gives identical results with the standard definition in case of GLMs. Note that it is possible to construct a state space model where this definition is not meaningful (for example the covariance matrix H_t can contain zeros on diagonal).

Examples

Run this code
model <- SSModel(sr ~ pop15 + pop75 + dpi + ddpi, data = LifeCycleSavings)
out <- KFS(model, filtering = "state", smoothing = "none")
# estimate sigma2
model["H"] <- mean(c(out$v[1:out$d][out$Finf==0]^2/out$F[1:out$d][out$Finf==0],
                     out$v[-(1:out$d)]^2/out$F[-(1:out$d)]))
c(hatvalues(KFS(model)))

Run the code above in your browser using DataLab