dlmSmooth: DLM smoothing

View source: R/DLM.R

dlmSmoothR Documentation

DLM smoothing

Description

The function apply Kalman smoother to compute smoothed values of the state vectors, together with their variance/covariance matrices.

Usage

dlmSmooth(y, ...)
## Default S3 method:
dlmSmooth(y, mod, ...)
## S3 method for class 'dlmFiltered'
dlmSmooth(y, ..., debug = FALSE)

Arguments

y

an object used to select a method.

...

futher arguments passed to or from other methods.

mod

an object of class "dlm".

debug

if debug=FALSE, faster C code will be used, otherwise all the computations will be performed in R.

Details

The default method returns means and variances of the smoothing distribution for a data vector (or matrix) y and a model mod.

dlmSmooth.dlmFiltered produces the same output based on a dlmFiltered object, typically one produced by a call to dlmFilter.

The calculations are based on the singular value decomposition (SVD) of the relevant matrices. Variance matrices are returned in terms of their SVD.

Value

A list with components

s

Time series (or matrix) of smoothed values of the state vectors. The series starts one time unit before the first observation.

U.S

See below.

D.S

Together with U.S, it gives the SVD of the variances of the smoothing errors.

Warning

The observation variance V in mod must be nonsingular.

Author(s)

Giovanni Petris GPetris@uark.edu

References

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.
Giovanni Petris (2010), An R Package for Dynamic Linear Models. Journal of Statistical Software, 36(12), 1-16. https://www.jstatsoft.org/v36/i12/.
Petris, Petrone, and Campagnoli, Dynamic Linear Models with R, Springer (2009).

See Also

See dlm for a description of dlm objects, dlmSvd2var to obtain a variance matrix from its SVD, dlmFilter for Kalman filtering, dlmMLE for maximum likelihood estimation, and dlmBSample for drawing from the posterior distribution of the state vectors.

Examples


s <- dlmSmooth(Nile, dlmModPoly(1, dV = 15100, dW = 1470))
plot(Nile, type ='o')
lines(dropFirst(s$s), col = "red")

## Multivariate
set.seed(2)
tmp <- dlmRandom(3, 5, 20)
obs <- tmp$y
m <- tmp$mod
rm(tmp)

f <- dlmFilter(obs, m)
s <- dlmSmooth(f)
all.equal(s, dlmSmooth(obs, m))

dlm documentation built on Sept. 21, 2024, 9:06 a.m.