mvInnovations: Multivariate Innovations

View source: R/mvInnovations.R

mvInnovationsR Documentation

Multivariate Innovations

Description

Function mvInnovations computes the multivariate versions of one step-ahead prediction errors and their variances using the output of KFS.

Usage

mvInnovations(x)

Arguments

x

Object of class KFS.

Value

v

Multivariate prediction errors v_{t} = y_{t} - Z_{t}a_{t}

F

Prediction error variances Var(v_{t}).

Finf

Diffuse part of F_t.

Examples


# Compute the filtered estimates based on the KFS output

filtered <- function(x) {
  innov <- mvInnovations(x)
  att <- window(x$a, end = end(x$a) - 1)
  tvz <- attr(x$model,"tv")[1]
  
  for (i in 1:nrow(att)) {
    att[i,] <- att[i,] + 
      x$P[,,i] %*% 
      t(solve(innov$F[,,i], x$model$Z[, , tvz * (i - 1) + 1, drop = FALSE])) %*%
      innov$v[i, ]
  }
  att
}

KFAS documentation built on Sept. 8, 2023, 5:56 p.m.