Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mvInnovations

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,i] = 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

Kalman Filter and Smoother for Exponential Family State Space Models

v1.4.5
GPL (>= 2)
Authors
Jouni Helske [aut, cre] (<https://orcid.org/0000-0001-7130-793X>)
Initial release
2021-05-10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.