sim_smoother {bssm} | R Documentation |
Simulation Smoothing
Description
Function sim_smoother
performs simulation smoothing i.e. simulates
the states from the conditional distribution p(\alpha | y, \theta)
for linear-Gaussian models.
Usage
sim_smoother(model, nsim, seed, use_antithetic = TRUE, ...)
## S3 method for class 'lineargaussian'
sim_smoother(
model,
nsim = 1,
seed = sample(.Machine$integer.max, size = 1),
use_antithetic = TRUE,
...
)
## S3 method for class 'nongaussian'
sim_smoother(
model,
nsim = 1,
seed = sample(.Machine$integer.max, size = 1),
use_antithetic = TRUE,
...
)
Arguments
model |
Model of class |
nsim |
Number of samples (positive integer). Suitable values depend on the model and the data, and while larger values provide more accurate estimates, the run time also increases with respect to to the number of samples, so it is generally a good idea to test the filter first with a small number of samples, e.g., less than 100. |
seed |
Seed for the C++ RNG (positive integer). |
use_antithetic |
Logical. If |
... |
Ignored. |
Details
For non-Gaussian/non-linear models, the simulation is based on the approximating Gaussian model.
Value
An array containing the generated samples.
Examples
# only missing data, simulates from prior
model <- bsm_lg(rep(NA, 25), sd_level = 1,
sd_y = 1)
# use antithetic variable for location
sim <- sim_smoother(model, nsim = 4, use_antithetic = TRUE, seed = 1)
ts.plot(sim[, 1, ])
cor(sim[, 1, ])