Draws random samples of the specified model conditional on the observed data.
SimSmoother(object, nsim = 1, components = TRUE)
A statespacer object as returned by statespacer
.
Number of random samples to draw. Defaults to 1
.
Boolean indicating whether the components of the model should be extracted in each of the random samples.
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
.
# 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')