Draws random samples of the specified model conditional on the observed data.

SimSmoother(object, nsim = 1, components = TRUE)

Arguments

object

A statespacer object as returned by statespacer.

nsim

Number of random samples to draw. Defaults to 1.

components

Boolean indicating whether the components of the model should be extracted in each of the random samples.

Value

A list containing the simulated state parameters and disturbances. In addition, it returns the components as specified by the State Space model if components = TRUE. Each of the objects are arrays, where the first dimension equals the number of time points, the second dimension the number of state parameters, disturbances, or dependent variables, and the third dimension equals the number of random samples nsim.

Author

Dylan Beijers, dylanbeijers@gmail.com

Examples

# Fits a local level model for the Nile data
library(datasets)
y <- matrix(Nile)
fit <- statespacer(initial = 10, y = y, local_level_ind = TRUE)

# Obtain random sample using the fitted model
sim <- SimSmoother(fit, nsim = 1, components = TRUE)

# Plot the simulated level against the smoothed level of the original data
plot(sim$level[, 1, 1], type = 'p')
lines(fit$smoothed$level, type = 'l')