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 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). 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 TRUE (default), use antithetic variable for location in simulation smoothing. Ignored for ssm_mng models.

...

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, ])

[Package bssm version 2.0.2 Index]