Learn R Programming

stsm (version 1.7)

datagen.stsm: Generate Data from a Structural Time Series Model

Description

This function simulates data from a structural time series model defined in an object of class stsm.

Usage

datagen.stsm(n, model = list(), SigmaEV, labels, n0 = 20, freq = 1, old.version = FALSE)

Arguments

n
number of observations in the output time series.
model
a list containing the matrices of the state space for of the structural model.
SigmaEV
a list containing the elements values and vectors, they are respectively the eigen values and vectors of the covariance matrix of the disturbance terms in the state equation of the model.
labels
optional vector of characters giving the names of the unobserved components in the model.
n0
number of warming-up observations (they are not included in the output data).
freq
number of observations per unit of time, e.g. freq = 4 for quarterly data.
old.version
logical. If TRUE, results obtained in a previous version of the package are reproduced.

Value

A list containing the output time series and the underlying components of the model.

Details

The matrices in the argument model must follow the conventions of an object of class stsm as returned by char2numeric.

For compatibility with previous versions of the package, old.version = TRUE generates random values from the multivariate normal distribution using the function rmvnorm with pre0.9_9994 = TRUE. mvrnorm.version = FALSE uses the theoretical expression that is commonly used to define random draws for the multivariate normal distribution.

See Also

sim-data, stsm.

Examples

Run this code
# generate a quarterly series from a local level plus seasonal model
# the data set 'llmseas' is generated as follows (first series)
pars <- c(var1 = 300, var2 = 10, var3 = 100)
m <- stsm.model(model = "llm+seas", y = ts(seq(120), frequency = 4), 
  pars = pars, nopars = NULL)
ss <- char2numeric(m)
set.seed(123)
y <- datagen.stsm(n = 120, model = list(Z = ss$Z, T = ss$T, H = ss$H, Q = ss$Q), 
  n0 = 20, freq = 4, old.version = TRUE)$data

data("llmseas")
all.equal(y, llmseas)

Run the code above in your browser using DataLab