Learn R Programming

tsfa (version 2021.1-3)

simulate.TSFmodel: Simulate a Time Series Factor Model

Description

Simulate a TSFmodel to generate time series data (indicators) using factors and loadings from the model.

Usage

# S3 method for TSFmodel
simulate(model, f=factors(model), Cov=model$Omega,
       sd=NULL, noise=NULL, rng=NULL, noise.model=NULL, ...)

Arguments

model

A TSFmodel.

f

Factors to use with the model.

Cov

covariance of the idiosyncratic term.

noise
rng
noise.model
...

arguments passed to other methods.

Value

A time series matrix.

Details

simulate.TSFmodel generates artifical data (indicators or measures) with a given TSFmodel (which has factors and loadings). The obj should be a TSFmodel. This might be a model constructed with TSFmodel or as returned by estTSF.ML.

The number of factor series is determined by the number of columns in the time series matrix f (the factors in the model object). This must also be the number of columns in the loadings matrix \(B\) (in the model object). The number of rows in the loadings matrix determines the number of indicator series generated (the number of columns in the matrix result). The number of rows in the time series factor matrix determines the number of time observations (periods) in the indicator series generated, that is, the number of rows in the matrix result.

simulate passes Cov, sd, noise, rng, and noise.model to makeTSnoise to generate the random idiosyncratic term \(\varepsilon_t\), which will have the same dimension as the generated indicator series that are returned. \(\varepsilon_t\) will have random distribution determined by other arguments passed to makeTSnoise. Note that the covariance of the generated indicator series \(y_t\) is also influenced by the covariance of the factors \(f\).

The calculation to give the generated artificial time series indicator data matrix \(y\) is

$$y_t = B f_t + \varepsilon_t.$$

simulate.TSFmodel can use a TSFmodel that has only B and f specified, but in this case one of Cov, sd, noise, or noise.model must be specified as the default Omega from the model is not available.

See Also

TSFmodel, estTSF.ML, simulate, tfplot.TSFmodel, explained.TSFmodel

Examples

Run this code
# NOT RUN {
  f <- matrix(c(2+sin(pi/100:1),5+3*sin(2*pi/5*(100:1))),100,2)
  B <- t(matrix(c(0.9, 0.1,
		  0.8, 0.2,
		  0.7, 0.3,
                  0.5, 0.5, 
		  0.3, 0.7,
 		  0.1, 0.9), 2,6))

  z <- simulate(TSFmodel(B, f=f), sd=0.01)
  tfplot(z)
# }

Run the code above in your browser using DataLab