sim_smoother | R Documentation |
Function sim_smoother
performs simulation smoothing i.e. simulates
the states from the conditional distribution p(\alpha | y, \theta)
for linear-Gaussian models.
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,
...
)
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. |
For non-Gaussian/non-linear models, the simulation is based on the approximating Gaussian model.
An array containing the generated samples.
# 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, ])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.