| GARCH Toolbox™ | ![]() |
The third part of the example uses the same estimated model, coeff, as in Forecasting. This part of the example simulates 20000 realizations for the same 30-day period.
The example explicitly specifies the needed presample data:
It uses the inferred residuals (eFit) and standard deviations (sFit) from Estimating the Model as the presample inputs PreInnovations and PreSigmas, respectively.
It uses the nasdaq return series as the presample input PreSeries.
Because all inputs are vectors, garchsim applies the same vector to each column of the corresponding outputs, Innovations, Sigmas, and Series. In this context, called dependent-path simulation, all simulated sample paths share a common conditioning set and evolve from the same set of initial conditions. This enables Monte Carlo simulation of forecasts and forecast error distributions.
Specify PreInnovations, PreSigmas, and PreSeries as matrices, where each column is a realization, or as single-column vectors. In either case, they must have a sufficient number of rows to initiate the simulation (see Running Simulations With User-Specified Presample Data).
For this application of Monte Carlo simulation, the example generates a relatively large number of realizations, or sample paths, so that it can aggregate across realizations. Because each realization corresponds to a column in the garchsim time-series output arrays, the output arrays are large, with many columns.
Simulate 20000 paths (columns):
nPaths = 20000; % Define the number of realizations.
randn('state',0);
rand('twister',0);
[eSim,sSim,ySim] = garchsim(coeff,horizon,nPaths,...
[],[],[], eFit,sFit,nasdaq);
Each time-series output that garchsim returns is an array of size horizon-by-nPaths, or 30-by-20000. Although more realizations (for example, 100000) provide more accurate simulation results, you may want to decrease the number of paths (for example, to 10000) to avoid memory limitations.

Because garchsim needs only the last, or most recent, observation of each, the following command produces identical results:
randn('state',0);
rand('twister',0);
[eSim,sSim,ySim] = garchsim(coeff,horizon,nPaths, ...
[],[],[], eFit(end),sFit(end),nasdaq(end));
![]() | Forecasting | Comparing Forecasts with Simulation Results | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |