Last chance! 50% off unlimited learning
Sale ends in
"dlmFiltered"
. Methods for residuals
and tsdiag
for objects of class "dlmFiltered"
exist.dlmFilter(y, mod, debug = FALSE, simplify = FALSE)
y
can be a vector, a matrix, a univariate or
multivariate time series.dlm
, or a list with components
m0
, C0
,
FF
, V
, GG
, W
, and optionally JFF
,
JV
, JGG
, JW
FALSE
, faster C code will be used, otherwise
all the computations will be performed in R.simplify
is
FALSE
, the returned list has class "dlmFiltered"
.simplify
is FALSE
.mod
(possibly simplified).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]])
.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]])
.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)
unlist(nileMod[c("V","W")])
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))
Run the code above in your browser using DataLab