Learn R Programming

MSGARCH (version 1.3)

Sim: Simulation of MSGARCH processes.

Description

Method for simulating MSGARCH processes.

Usage

Sim(object, ...)

# S3 method for MSGARCH_SPEC Sim(object, data = NULL, n.ahead = 1L, n.sim = 1L, par = NULL, n.burnin = 500L, ...)

# S3 method for MSGARCH_ML_FIT Sim(object, new.data = NULL, n.ahead = 1L, n.sim = 1L, n.burnin = 500L, ...)

# S3 method for MSGARCH_MCMC_FIT Sim(object, new.data = NULL, n.ahead = 1L, n.sim = 1L, n.burnin = 500L, ...)

Arguments

object

Model specification of class MSGARCH_SPEC created with CreateSpec or fit object of type MSGARCH_ML_FIT created with FitML or MSGARCH_MCMC_FIT created with FitMCMC.

...

Not used. Other arguments to Sim.

data

Vector (of size T) of observations for filtering.

n.ahead

Simulation length. (Default: n.ahead = 1L)

n.sim

Number of simulations. (Default: n.sim = 1L)

par

Vector (of size d) or matrix (of size n.ahead x d) of parameter estimates where d must have the same length as the default parameters of the specification.

n.burnin

Burnin period discarded (first simulation draws). Not used when data is provided. (Default: n.burnin = 500L)

new.data

Vector (of size T*) of new observations.. (Default new.data = NULL)

Value

A list of class MSGARCH_SIM with the following elements:.

  • draw: Matrix (of size n.ahead x n.sim) of simulated draws.

  • state: Matrix (of size n.ahead x n.sim) of simulated states.

  • CondVol: Array (of size n.ahead x n.sim x K) of simulated conditional volatility.

The MSGARCH_SIM class contains the plot method.

Details

If a matrix of parameters estimates is provided, n.sim simuations will be done for each row.. When data is provided, the conditional variance and state probability are update up to time T + T* + 1 before beginning the simulations. If data = NULL, new simulations will start from scratch where the first n.burnin simulation will be discarded. Passing a MSGARCH_ML_FIT or MSGARCH_MCMC_FIT object will automatically filter the corresponding data in the object and start the simulation ahead of data.

Examples

Run this code
# NOT RUN {
# create model specification
# MS(2)-GARCH(1,1)-Normal (default)
spec <- CreateSpec()

# generate process
par.sim <- c(0.1,0.6,0.2,0.2,0.8,0.1,0.99,0.01)
set.seed(123)
sim <- Sim(object = spec, n.ahead = 1000L, n.sim = 1L, par = par.sim, n.burnin = 500L)
plot(sim)

# generate process after filtering for fitted model
# load data
data("SMI", package = "MSGARCH")

# fit the model on the data with ML estimation
fit <- FitML(spec = spec, data = SMI)

set.seed(123)
sim <- Sim(fit, n.ahead = 30L, n.sim = 1000L)
plot(sim)
# }

Run the code above in your browser using DataLab