View source: R/particle_smoother.R
particle_smoother | R Documentation |
Function particle_smoother
performs particle smoothing
based on either bootstrap particle filter (Gordon et al. 1993),
\psi
-auxiliary particle filter (\psi
-APF) (Vihola et al. 2020),
extended Kalman particle filter (Van Der Merwe et al. 2001),
or its version based on iterated EKF (Jazwinski, 1970).
The smoothing phase is based on the filter-smoother algorithm by
Kitagawa (1996).
particle_smoother(model, particles, ...)
## S3 method for class 'lineargaussian'
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),
...
)
model |
A model object of class |
particles |
Number of particles as a positive integer. Suitable values depend on the model, the data, and the chosen algorithm. While larger values provide more accurate estimates, the run time also increases with respect to the number of particles, so it is generally a good idea to test the filter first with a small number of particles, e.g., less than 100. |
... |
Ignored. |
method |
Choice of particle filter algorithm.
For Gaussian and non-Gaussian models with linear dynamics,
options are |
seed |
Seed for the C++ RNG (positive integer). |
max_iter |
Maximum number of iterations used in Gaussian approximation, as a positive integer. Default is 100 (although typically only few iterations are needed). |
conv_tol |
Positive tolerance parameter used in Gaussian approximation. Default is 1e-8. |
iekf_iter |
Non-negative integer. If zero (default), first
approximation for non-linear Gaussian models is obtained from extended
Kalman filter. If |
L |
Positive integer defining the discretization level for SDE model. |
See one of the vignettes for \psi
-APF in case of nonlinear models.
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
).
Gordon, NJ, Salmond, DJ, Smith, AFM (1993). Novel approach to nonlinear/non-Gaussian Bayesian state estimation. IEE Proceedings-F, 140, 107-113. https://doi.org/10.1049/ip-f-2.1993.0015
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
Van Der Merwe, R, Doucet, A, De Freitas, N, Wan, EA (2001). The unscented particle filter. In Advances in neural information processing systems, p 584-590.
Jazwinski, A 1970. Stochastic Processes and Filtering Theory. Academic Press.
Kitagawa, G (1996). Monte Carlo filter and smoother for non-Gaussian nonlinear state space models. Journal of Computational and Graphical Statistics, 5, 1-25. https://doi.org/10.2307/1390750
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.