Method for simulation from a variety of univariate GARCH models.
ugarchsim(fit, n.sim = 1000, n.start = 0, m.sim = 1,
startMethod = c("unconditional", "sample"), presigma = NA, prereturns = NA,
preresiduals = NA, rseed = NA, custom.dist = list(name = NA, distfit = NA),
mexsimdata = NULL, vexsimdata = NULL, ...)
The simulation horizon.
The burn-in sample.
The number of simulations.
Starting values for the simulation. Valid methods are “unconditional” for the expected values given the density, and “sample” for the ending values of the actual data from the fit object.
Allows the starting sigma values to be provided by the user.
Allows the starting return data to be provided by the user.
Allows the starting residuals to be provided by the user.
Optional seeding value(s) for the random number generator. For m.sim>1, it is
possible to provide either a single seed to initialize all values, or one seed
per separate simulation (i.e. m.sim seeds). However, in the latter case this may
result in some slight overhead depending on how large m.sim is.
It is now recommended not to provide a value (i.e., keep the default of
rseed == NA
) and to call set.seed
only once in the beginning of
the session, which will ensure reproducibility.
Optional density with fitted object from which to simulate. See notes below for details.
List of matrices (size of list m.sim, with each matrix having n.sim rows) of simulated external regressor-in-mean data. If the fit object contains external regressors in the mean equation, this must be provided else will be assumed zero.
List of matrices (size of list m.sim, with each matrix having n.sim rows) of simulated external regressor-in-variance data. If the fit object contains external regressors in the mean equation, this must be provided else will be assumed zero.
For the multiplicative component sGARCH model (mcsGARCH), the additional argument ‘DailyVar’ is required and should be an xts object of length floor(n.sim/increments-per-day) by m.sim of the the daily simulated variance to use with the intraday data. In the case of the realized GARCH (realGARCH) model, the optional argument ‘prerealized’ allows to pass starting values of the realized volatility (should be of length q as was set in the ‘garchOrder(q,p)’ in the specification)
A '>uGARCHsim
object containing details of the GARCH simulation.
The custom.dist option allows for defining a custom density which exists in the users workspace with methods for “r” (sampling, e.g. rnorm) and “d” (density e.g. dnorm). It must take a single fit object as its second argument. Alternatively, custom.dist can take any name in the name slot (e.g.“sample”) and a matrix in the fit slot with dimensions equal to m.sim (columns) and n.sim (rows). It is understood that what is supplied are the standardized (0,1) innovations and not the unstandardized residuals. The usefulness of this becomes apparent when one is considering the copula-GARCH approach or the bootstrap method.
For specification ugarchspec
, fitting ugarchfit
,
filtering ugarchfilter
, forecasting ugarchforecast
,
rolling forecast and estimation ugarchroll
, parameter distribution
and uncertainty ugarchdistribution
, bootstrap forecast
ugarchboot
.
# NOT RUN {
# Basic GARCH(1,1) Spec
data(dmbp)
spec = ugarchspec()
fit = ugarchfit(data = dmbp[,1], spec = spec)
sim = ugarchsim(fit,n.sim=1000, n.start=1, m.sim=1, startMethod="sample")
sim
head(sigma(sim))
# }
Run the code above in your browser using DataLab