Learn R Programming

bssm (version 1.1.7-1)

fast_smoother: Kalman Smoothing

Description

Methods for Kalman smoothing of the states. Function fast_smoother computes only smoothed estimates of the states, and function smoother computes also smoothed variances.

Usage

fast_smoother(model, ...)

# S3 method for gaussian fast_smoother(model, ...)

smoother(model, ...)

# S3 method for gaussian smoother(model, ...)

Arguments

model

Model to be approximated. Should be of class bsm_ng, ar1_ng svm, ssm_ung, or ssm_mng, or ssm_nlg, i.e. non-gaussian or non-linear bssm_model.

...

Ignored.

Value

Matrix containing the smoothed estimates of states, or a list with the smoothed states and the variances.

Details

For non-Gaussian models, the smoothing is based on the approximate Gaussian model.

Examples

Run this code
# NOT RUN {
model <- bsm_lg(Nile, 
  sd_level = tnormal(120, 100, 20, min = 0),
  sd_y = tnormal(50, 50, 25, min = 0),
  a1 = 1000, P1 = 200)
ts.plot(cbind(Nile, fast_smoother(model)), col = 1:2)
model <- bsm_lg(Nile, 
  sd_y = tnormal(120, 100, 20, min = 0),
  sd_level = tnormal(50, 50, 25, min = 0),
  a1 = 1000, P1 = 500^2)

out <- smoother(model)
ts.plot(cbind(Nile, out$alphahat), col = 1:2)
ts.plot(sqrt(out$Vt[1, 1, ]))
# }

Run the code above in your browser using DataLab