Learn R Programming

bssm (version 1.1.7-1)

sim_smoother: 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 gaussian sim_smoother( model, nsim = 1, seed = sample(.Machine$integer.max, size = 1), use_antithetic = TRUE, ... )

# S3 method for nongaussian sim_smoother( model, nsim = 1, seed = sample(.Machine$integer.max, size = 1), use_antithetic = TRUE, ... )

Arguments

model

Model of class bsm_lg, ar1_lg ssm_ulg, or ssm_mlg, or one of the non-gaussian models bsm_ng, ar1_ng svm, ssm_ung, or ssm_mng.

nsim

Number of samples (positive integer).

seed

Seed for the random number generator (positive integer).

use_antithetic

Logical. If TRUE (default), use antithetic variable for location in simulation smoothing. Ignored for ssm_mng models.

...

Ignored.

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 {
# 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, ])
# }

Run the code above in your browser using DataLab