Learn R Programming

bssm (version 0.1.8)

sim_smoother: Simulation Smoothing

Description

Function sim_smoother performs simulation smoothing i.e. simulates the states from the conditional distribution \(p(\alpha | y, \theta)\).

Usage

sim_smoother(object, nsim, seed, use_antithetic = FALSE, ...)

# S3 method for gssm sim_smoother(object, nsim = 1, seed = sample(.Machine$integer.max, size = 1), use_antithetic = FALSE, method = "dk", ...)

# S3 method for bsm sim_smoother(object, nsim = 1, seed = sample(.Machine$integer.max, size = 1), use_antithetic = FALSE, method = "dk", ...)

# S3 method for ar1 sim_smoother(object, nsim = 1, seed = sample(.Machine$integer.max, size = 1), use_antithetic = FALSE, method = "dk", ...)

# S3 method for ngssm sim_smoother(object, nsim = 1, seed = sample(.Machine$integer.max, size = 1), use_antithetic = FALSE, ...)

# S3 method for ng_bsm sim_smoother(object, nsim = 1, seed = sample(.Machine$integer.max, size = 1), use_antithetic = FALSE, ...)

# S3 method for svm sim_smoother(object, nsim = 1, seed = sample(.Machine$integer.max, size = 1), use_antithetic = FALSE, ...)

# S3 method for ng_ar1 sim_smoother(object, nsim = 1, seed = sample(.Machine$integer.max, size = 1), use_antithetic = FALSE, ...)

Arguments

object

Model object.

nsim

Number of independent samples.

seed

Seed for the random number generator.

use_antithetic

Use an antithetic variable for location. Default is FALSE. Only used if method is "dk".

...

Ignored.

method

If "dk" (default), use simulation smoothing algorithm by Durbin and Koopman (2002). If "psi", use twisted SMC. Only used for Gaussian models of class "gssm", "bsm", and "ar1".

Value

An array containing the generated samples.

Details

For non-Gaussian/non-linear models, the simulation is based on the approximating Gaussian model.

Examples

Run this code
# NOT RUN {
model <- bsm(rep(NA, 50), sd_level = uniform(1,0,5), sd_y = uniform(1,0,5))
sim <- sim_smoother(model, 12)
ts.plot(sim[, 1, ])
# }

Run the code above in your browser using DataLab