dlmFilter {dlm} | R Documentation |
The functions applies Kalman filter to compute filtered
values of the state vectors, together with their
variance/covariance matrices. By default the function returns an object
of class "dlmFiltered"
. Methods for residuals
and tsdiag
for objects of class "dlmFiltered"
exist.
dlmFilter(y, mod, debug = FALSE, simplify = FALSE)
y |
the data. y can be a vector, a matrix, a univariate or
multivariate time series. |
mod |
an object of class dlm , or a list with components
m0 , C0 ,
FF , V , GG , W , and optionally JFF ,
JV , JGG , JW , and X , defining the model
and the parameters of the prior distribution. |
debug |
if FALSE , faster C code will be used, otherwise
all the computations will be performed in R. |
simplify |
should the data be included in the output? |
The calculations are based on the singular value decomposition (SVD) of the relevant matrices. Variance matrices are returned in terms of their SVD.
Missing values are allowed in y
.
A list with the components described below. If simplify
is
FALSE
, the returned list has class "dlmFiltered"
.
y |
The input data, coerced to a matrix. This is present only if
simplify is FALSE . |
mod |
The argument mod (possibly simplified). |
m |
Time series (or matrix) of filtered values of the state vectors. The series starts one time unit before the first observation. |
U.C |
See below. |
D.C |
Together with U.C , it gives the SVD
of the variances of the estimation errors.
The variance of m_t-theta_t is given by
U.C[[t]] %*% diag(D.C[t,]^2) %*% t(U.C[[t]]) . |
a |
Time series (or matrix) of predicted values of the state vectors given the observations up and including the previous time unit. |
U.R |
See below. |
D.R |
Together with U.R , it gives the SVD
of the variances of the prediction errors.
The variance of a_t-theta_t is given by
U.R[[t]] %*% diag(D.R[t,]^2) %*% t(U.R[[t]]) . |
f |
Time series (or matrix) of one-step-ahead forecast of the observations. |
Giovanni Petris, GPetris@uark.edu
Zhang, Y. and Li, X.R., Fixed-interval smoothing algorithm based on singular value decomposition, Proceedings of the 1996 IEEE International Conference on Control Applications.
See dlm
for a description of dlm objects,
dlmSvd2var
to obtain a variance matrix from its SVD,
dlmMLE
for maximum likelihood estimation,
dlmSmooth
for Kalman smoothing, and
dlmBSample
for drawing from the posterior distribution
of the state vectors.
nileBuild <- function(par) { dlmModPoly(1, dV = exp(par[1]), dW = exp(par[2])) } nileMLE <- dlmMLE(Nile, rep(0,2), nileBuild); nileMLE$conv nileMod <- nileBuild(nileMLE$par) V(nileMod) W(nileMod) nileFilt <- dlmFilter(Nile, nileMod) nileSmooth <- dlmSmooth(nileFilt) plot(cbind(Nile, nileFilt$m[-1], nileSmooth$s[-1]), plot.type='s', col=c("black","red","blue"), ylab="Level", main="Nile river", lwd=c(1,2,2))