Kfiltertv | R Documentation |
Time-varying Kalman filter calculations
Kfiltertv(num, y, Atv, mu0, Sigma0, Phitv, Ups, Gam, Qtv, Rtv, input)
num |
the number of samples in the time-series |
y |
values of the time-series |
Atv |
q x p x n observation array |
mu0 |
p x 1 vector setting the mean of the system at time zero |
Sigma0 |
p x p variance matrix of the system at time zero |
Phitv |
p x p x n array reflecting autoregression of the state variables |
Ups |
p x r matrix with the coefficients/parameters relating the inputs to the system equation |
Gam |
q x r matrix with the coefficients/parameters relating the inputs to the observation equation |
Qtv |
p x p x n array of system stochastic variance; user needs to ensure positive definite |
Rtv |
q x q x n array observation stochastic variance; user needs to ensure positive definite |
input |
n x r array of the exogenous variables/covariates |
For the dimensions of the argument arrays, n
is the length of the
time-series, q
is the dimension of the observation variable(s),
p
is the dimension of the state variable(s), and r
isthe
dimension of the input variable(s).
This function is based on the
Kfilter
function of the astsa package, modified modified to
allow for time-varying terms for the Kalman filter. This modification
facilitates fitting a broader array of models and handling non-uniform
temporal spacing of samples. See the documentation for that function, and
the reference below for additional information.
A list of the following elements:
xp
one-step-ahead prediction of the state
Pp
mean square prediction error
xf
filter value of the state
Pf
mean square filter error
like
log-likelihood
innov
innovation series
sig
innovation covariances
Kn
last value of the gain, needed for smoothing
This function is used in the internal SSM log-likelihood functions for the models. The user will not need to use this they create their own model-fitting functions.
John Fricks (jfricks@asu.edu)
Shumway, R. H., and D. S. Stoffer. 2017. Time Series Analysis and its Applications (4th Ed.) Springer International.
y <- sim.GRW(ms = 0, vs = 1, vp = 0)
n <- length(y)
kf <- Kfiltertv(n ,y = y$mm, Atv = array(1, dim = c(1,1,n)), mu0 = y$mm[1],
Sigma0 = y$vv[1]/y$nn[1], Phitv = array(1, dim = c(1,1,n)),
Ups = NULL, Gam = NULL, Qtv = array(1, dim = c(1,1,n)),
Rtv = array(0, dim = c(1,1,n)), input = NULL)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.