simulate.fitted_dlm {kDGLM}R Documentation

Draw samples from the distribution of the latent states

Description

This is function draws samples from the latent states using the backward sampling algorithm. See West and Harrison (1997), chapter 15, for details.

Usage

## S3 method for class 'fitted_dlm'
simulate(object, nsim, seed = NULL, lag = -1, ...)

Arguments

object

fitted_dlm: A fitted model from which to sample.

nsim

integer: The number of samples to draw.

seed

integer: An object specifying if and how the random number generator should be initialized.

lag

integer: The relative offset for forecast. Values for time t will be calculated based on the filtered values of time t-h. If lag is negative, then the smoothed distribution for the latent states will be used.

...

Extra arguments passed to the plot method.

Value

A list containing the following values:

See Also

Other auxiliary functions for fitted_dlm objects: coef.fitted_dlm(), eval_dlm_norm_const(), fit_model(), forecast.fitted_dlm(), smoothing(), update.fitted_dlm()

Examples


structure <- polynomial_block(mu = 1, D = 0.95) +
  polynomial_block(V = 1, D = 0.95)

outcome <- Normal(mu = "mu", V = "V", data = cornWheat$corn.log.return[1:500])
fitted.data <- fit_model(structure, corn = outcome)

sample <- simulate(fitted.data, 5000)


[Package kDGLM version 1.2.0 Index]