GARCH Toolbox | ![]() ![]() |
Simulating Sample Paths
The section Analysis and Estimation Example Using the Default Model models the equity series of a hypothetical company, the XYZ Corporation, using the default model. This section uses the resulting model
to simulate sample paths, using the simulation function garchsim
, for return series, innovations, and conditional standard deviation processes. You can think of garchsim
as a filter that you can use to generate a (possibly) correlated return series {yt} from a white noise input series {t}.
Use the following commands to restore your workspace if necessary. This example omits the estimation output to save space.
load xyz xyz = price2ret(prices); [coeff, errors, LLF, innovations, sigma] = garchfit(xyz); coeff coeff = Comment: 'Mean: ARMAX(0,0,0); Variance: GARCH(1,1)' R: 0 M: 0 P: 1 Q: 1 Distribution: 'Gaussian' C: 4.9183e-004 AR: [] MA: [] Regress: [] K: 8.2736e-007 GARCH: 0.9628 ARCH: 0.0318 FixC: [] FixAR: [] FixMA: [] FixRegress: [] FixK: [] FixGARCH: [] FixARCH: [] Optimization: [1x1 struct]
Using Default Inputs
Now call garchsim
to simulate sample paths using the model in coeff
. This command accepts garchsim
defaults for:
1
100
0
The result is a single realization (i.e., one sample path) of 100 observations each for the innovations {t}, conditional standard deviations {
t}, and returns {yt} processes. These processes are designated by the output variables
e
, s
, and y
, respectively.
Simulating a Much Longer Path
However, accurate GARCH modeling typically requires a few years worth of data. If there are 250 trading days per year, 1000 observations would be a more useful sample.
[e,s,y] = garchsim(coeff, 1000); whos e s y Name Size Bytes Class e 1000x1 8000 double array s 1000x1 8000 double array y 1000x1 8000 double array Grand total is 3000 elements using 24000 bytes
The result is a single realization of 1000 observations (roughly four years of data) for each of {t}, {
t}, and {yt}. Plot the
garchsim
output data to see what it looks like.
Figure 2-14: A Single Realization of 1000 Observations
Simulating Multiple Paths
However, Monte Carlo simulation requires multiple independent paths. Use the same model to simulate 1000 paths of 200 observations each.
[e,s,y] = garchsim(coeff, 200, 1000); whos e s y Name Size Bytes Class e 200x1000 1600000 double array s 200x1000 1600000 double array y 200x1000 1600000 double array Grand total is 600000 elements using 4800000 bytes
In this example, {t}, {
t}, and {yt} are 200-by-1000 element matrices. These are relatively large arrays, and demand large chunks of memory. In fact, because of the way the GARCH Toolbox manages transients, simulating this data requires more memory than the 4800000 bytes indicated above.
![]() | Simulation | Transients in the Simulation Process | ![]() |