Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

particle_smoother

Particle Smoothing


Description

Function particle_smoother performs particle smoothing based on either bootstrap particle filter [1], ψ-auxiliary particle filter (ψ-APF) [2], or extended Kalman particle filter [3] (or its iterated version [4]). The smoothing phase is based on the filter-smoother algorithm by [5].

Usage

particle_smoother(model, particles, ...)

## S3 method for class 'gaussian'
particle_smoother(
  model,
  particles,
  method = "psi",
  seed = sample(.Machine$integer.max, size = 1),
  ...
)

## S3 method for class 'nongaussian'
particle_smoother(
  model,
  particles,
  method = "psi",
  seed = sample(.Machine$integer.max, size = 1),
  max_iter = 100,
  conv_tol = 1e-08,
  ...
)

## S3 method for class 'ssm_nlg'
particle_smoother(
  model,
  particles,
  method = "bsf",
  seed = sample(.Machine$integer.max, size = 1),
  max_iter = 100,
  conv_tol = 1e-08,
  iekf_iter = 0,
  ...
)

## S3 method for class 'ssm_sde'
particle_smoother(
  model,
  particles,
  L,
  seed = sample(.Machine$integer.max, size = 1),
  ...
)

Arguments

model

Model.

particles

Number of samples for particle filter.

...

Ignored.

method

Choice of particle filter algorithm. For Gaussian and non-Gaussian models with linear dynamics, options are "bsf" (bootstrap particle filter, default for non-linear models) and "psi" (ψ-APF, the default for other models), and for non-linear models options "ekf" (extended Kalman particle filter) is also available.

seed

Seed for RNG.

max_iter

Maximum number of iterations used in Gaussian approximation. Used ψ-APF.

conv_tol

Tolerance parameter used in Gaussian approximation. Used ψ-APF.

iekf_iter

If zero (default), first approximation for non-linear Gaussian models is obtained from extended Kalman filter. If iekf_iter > 0, iterated extended Kalman filter is used with iekf_iter iterations.

L

Integer defining the discretization level.

Details

See one of the vignettes for ψ-APF in case of nonlinear models.

Value

List with samples (alpha) from the smoothing distribution and corresponding weights (weights), as well as smoothed means and covariances (alphahat and Vt) of the states and estimated log-likelihood (logLik).

References

[1] Gordon, N. J., Salmond, D. J., & Smith, A. F. M. (1993). Novel approach to nonlinear/non-Gaussian Bayesian state estimation. IEE Proceedings-F, 140, 107–113. [2] Vihola, M, Helske, J, Franks, J. Importance sampling type estimators based on approximate marginal Markov chain Monte Carlo. Scand J Statist. 2020; 1– 38. https://doi.org/10.1111/sjos.12492 [3] Van Der Merwe, R., Doucet, A., De Freitas, N., & Wan, E. A. (2001). The unscented particle filter. In Advances in neural information processing systems (pp. 584-590). [4] Jazwinski, A. 1970. Stochastic Processes and Filtering Theory. Academic Press. [5] Kitagawa, G. (1996). Monte Carlo filter and smoother for non-Gaussian nonlinear state space models. Journal of Computational and Graphical Statistics, 5, 1–25.

Examples

set.seed(1)
x <- cumsum(rnorm(100))
y <- rnorm(100, x)
model <- ssm_ulg(y, Z = 1, T = 1, R = 1, H = 1, P1 = 1)
system.time(out <- particle_smoother(model, particles = 1000))
# same with simulation smoother:
system.time(out2 <- sim_smoother(model, particles = 1000, use_antithetic = TRUE))
ts.plot(out$alphahat, rowMeans(out2), col = 1:2)

bssm

Bayesian Inference of Non-Linear and Non-Gaussian State Space Models

v1.1.4
GPL (>= 2)
Authors
Jouni Helske [aut, cre] (<https://orcid.org/0000-0001-7130-793X>), Matti Vihola [aut] (<https://orcid.org/0000-0002-8041-7222>)
Initial release
2021-04-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.