Software Implementation and Testing of GARCH Models
Software Implementation and Testing of GARCH Models
+ +
+ +
p
j
j t i t
q
i
i t
t t t t
T
t t
h h
h N b x b y
1
2
1
1
0
1 0
) , 0 ( | ,
This process is described by q + 1 coefficients , , , 0 , q i
i
K p coefficients , , , 1 , p i
i
K mean
,
0
b k linear regression coefficients , , , 1 , k i
i
b K endogenous/exogenous variables
t
y and
t
x
respectively, shocks
t
, conditional variance
t
h , and the set of all information up to time t,
t
.
TR4/2000 NP3533 3
It should be noted that for p = 0 a GARCH(p,q) model is also called an ARCH(q) model.
Empirical studies on financial time series have shown that they are characterised by increased
conditional variance
t
h following negative shocks (bad news). The distribution of the shocks have
been also found to exhibit considerable leptokurtosis. Since the standard Gaussian GARCH model
cannot capture these effects various GARCH model extensions have been developed [6].
The asymmetric GARCH models considered here are:
AGARCH(p,q)-type1
+ + +
p
j
j t i i t
q
i
i t
h h
1
2
1
0
) (
AGARCH(p,q)-type2
+ + +
p
j
j t i i t i t
q
i
i t
h h
1
2
1
0
) | (|
GJR-GARCH(p,q), or Glosten, Jagannathan and Runkle GARCH [7]
+ + +
p
j
j t i i t t
q
i
i t
h S h
1
2
1
1
0
) (
where 1
t
S if 0 <
t
and 0
t
S if 0
t
+ + +
p
j
j t i
q
i
i t i i t
q
i
i t
h z z h
where
t
t
t
h
z
and [ ] | | E
i t
z
denotes the expected value of | |
i t
z
In all these models the shocks, ,
t
can either have a Gaussian distribution or Student's t-
distribution with a specified number of degrees of freedom.
In AGARCH-type1 the asymmetric effects are modelled via the extra parameter . For example,
in the standard GARCH(1,1) model when
1 t
h is fixed ) (
1
t t
h h is a parabola with a minimum
at . 0
1
t
The introduction of the additional parameter shifts the parabola horizontally so that
the minimum occurs at .
1
t
The conditional variance following negative shocks can
therefore be enhanced by choosing , 0 < so that ) ( ) (
1 1
>
t t
h h for . 0
1
>
t
1
. In an EGARCH(1,1), if
0
1
< then a negative shock 0
1
<
t
increases the value of ,
t
h that is { } { }. ) ( ln ) ( ln
1 1
>
t t
z h z h
All the GARCH processes above are uniquely described by the parameter vector , where
, ) , , (
0
T T
b b ) , , , , , , , , , (
2 1 2 1 0
p q
T
K K and ) , , (
1 k
T
b b b K .
The GARCH model implementations here all rely on finding the value of which maximises the
conditional log-likelihood (objective) function
whereT is the number of terms in the sequence.
This is achieved by starting with an initial approximation for and then using numerical
optimisation to iterate to an acceptable solution. In all the GARCH estimation routines, apart
from EGARCH, an analytic expression for the Jacobian of the objective function was used for
the optimisation stage.
The standard errors for the parameter estimates can be computed by using the well known
result [8] that the maximum likelihood estimate for is asymptotically normal with mean
and covariance matrix
1
where (The Fisher Information Matrix) is given by:
3 The GARCH software
Here we list the available software for sequence generation, model parameter estimation, and
forecasting of regression-GARCH(p,q) sequences.
3.1 Generation
The following routines generate a given number of terms from various symmetric and
asymmetric GARCH(p,q) sequences.
Specification
AGARCH-type1
SUBROUTINE G05HKF (DIST, NUM, IP, IQ, THETA, GAMMA, DF, HT, YT, FCALL, RVEC, IFLAG)
1
]
1
T
i
T
lf
1
2
E
,
_
+
T
i i
i
i
h
h lf
1
2
) ( log
2
1
TR4/2000 NP3533 5
AGARCH-type2
SUBROUTINE G05HLF (DIST, NUM, IP, IQ, THETA, GAMMA, DF, HT, YT, FCALL, RVEC, IFLAG)
GJR-GARCH
SUBROUTINE G05HMF (DIST, NUM, IP, IQ, THETA, GAMMA, DF, HT, YT, FCALL, RVEC,IFLAG)
EGARCH
SUBROUTINE G05HNF (DIST, NUM, IP, IQ, THETA, DF, HT, YT, FCALL, RVEC, IFLAG)
The routine parameters have the following meanings:
Parameters
DIST - CHARACTER*1.
On entry, the type of distribution to use for
i
,
_
+
100
sin 7 . 0
100
1 t
The difficulty of modelling a GARCH(p,q) sequence depends on both p and q and also on how
much volatility memory there is in the process. Higher values of the
i
parameters give rise to
more volatility memory and are therefore harder to model accurately. Increasing the number of
model parameters will also make the model more difficult to model simply because there are
more variables to numerically optimise. This suggests the following order of difficulty ARCH(1),
ARCH(2), ARCH(3), GARCH(1,1), GARCH(1,2), GARCH(2,2),,etc.
It can be seen that a GARCH(1,2) model therefore represents a reasonably difficult test of the
software.
As previously mentioned, the simulations are used to calculate the mean of the parameter
estimates and the mean of the estimated standard errors. These values are then compared
with the true model parameter values and the actual standard errors of the parameter values.
The simulation results are presented in tables 1-20 of Section 6. The first column labelled
"Estimated Value" refers to the average parameter estimate using either 300 or 200 simulations.
The second column labelled "Estimated Standard Error" refers to the average of the standard
errors computed by the GARCH software. The third column labelled "Standard Error of
Estimates" refers to the actual standard error of the parameter estimates.
TR4/2000 NP3533 23
6 Monte Carlo results
AGARCH-type1
The AGARCH(1,2)-type1 simulations used here had the following parameters:
The series shocks were taken from either a Gaussian distribution or a Student's t-distribution, with
the number of degrees of freedom ( ) df set to 4.10.
The GARCH model parameters are output in the descending order, , , , , ,
1 2 1 0
then df (if
present) followed by 3 , , 1 , K i b
i
Gaussian distribution
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.2267 0.1712 0.1147 0.20
0.0873 0.0581 0.0607 0.10
0.1483 0.0903 0.0816 0.15
0.6944 0.1046 0.0793 0.70
-0.2408 0.3024 0.2398 -0.20
-1.4982 0.2586 0.2472 -1.50
2.5562 0.8595 0.7728 2.50
-3.0455 0.6588 0.5912 -3.00
Table 1: 400 observations and 300 simulations
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.2022 0.0669 0.0639 0.20
0.0924 0.0411 0.0396 0.10
0.1468 0.0572 0.0526 0.15
0.7050 0.0517 0.0473 0.70
-0.2109 0.1598 0.1380 -0.20
-1.5072 0.0962 0.0971 -1.50
2.5011 0.1619 0.1571 2.50
-3.0001 0.1695 0.1651 -3.00
Table 2: 1000 observations and 200 simulations
1
1000 2
1
100
sin 7 . 0
100
1
0 . 3 , 5 . 2 , 5 . 1 , 0
2 . 0
7 . 0 , 15 . 0 , 1 . 0 , 2 . 0
3
3
2
1
3 2 1 0
1 2 1 0
,
_
t
t
t
x
t
x
t
x
b b b b
k
TR4/2000 NP3533 24
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.2038 0.0467 0.0442 0.20
0.0959 0.0285 0.0283 0.10
0.1526 0.0395 0.0378 0.15
0.6986 0.0357 0.0332 0.70
-0.2076 0.0991 0.0944 -0.20
-1.5004 0.0708 0.0661 -1.50
2.4993 0.0576 0.0559 2.50
-2.9998 0.0952 0.0902 -3.00
Table 3: 2000 observations and 200 simulations
TR4/2000 NP3533 25
Student's t-distribution
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.1983 0.0706 0.0676 0.20
0.0937 0.0496 0.0592 0.10
0.1528 0.0684 0.0765 0.15
0.6970 0.0586 0.0582 0.70
-0.2321 0.1954 0.1850 -0.20
4.3246 0.6645 0.6189 4.10
-1.5000 0.0765 0.0812 -1.50
2.4907 0.1270 0.1274 2.00
-2.9950 0.1331 0.1354 -3.00
Table 4: 1000 observations and 200 simulations
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.2011 0.0463 0.0456 0.20
0.0975 0.0369 0.0337 0.10
0.1523 0.0485 0.0472 0.15
0.6954 0.0379 0.0394 0.70
-0.2203 0.1338 0.1213 -0.20
4.2278 0.4241 0.4069 4.10
-1.5064 0.0524 0.0517 -1.50
2.4974 0.0451 0.0439 2.00
-2.9987 0.0743 0.0709 -3.00
Table 5: 2000 observations and 200 simulations
TR4/2000 NP3533 26
AGARCH-type2
The AGARCH(1,2)-type2 simulations used here had the following parameters:
The series shocks were taken from either a Gaussian distribution or a Student's t-distribution, with
the number of degrees of freedom ( ) df set to 4.10.
The GARCH model parameters are output in the descending order, , , , , ,
1 2 1 0
then df (if
present) followed by 3 , , 1 , K i b
i
Gaussian distribution
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.1238 0.0651 0.0572 0.10
0.1020 0.0636 0.0627 0.10
0.1459 0.0847 0.0856 0.15
0.6778 0.0914 0.0845 0.70
-0.1097 0.1298 0.1116 -0.10
-1.5245 0.1900 0.1763 -1.50
2.4532 0.6022 0.5550 2.50
-2.9564 0.4586 0.4268 -3.00
Table 6: 400 observations and 300 simulations
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.1081 0.0324 0.0315 0.10
0.1015 0.0436 0.0402 0.10
0.1482 0.0587 0.0538 0.15
0.6918 0.0441 0.0487 0.70
-0.0993 0.0669 0.0613 -0.10
-1.5029 0.0678 0.0675 -1.50
2.4971 0.1083 0.1089 2.50
-2.9935 0.1116 0.1142 -3.00
Table 7: 1000 observations and 200 simulations
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.1048 0.0219 0.0215 0.10
0.1004 0.0310 0.0285 0.10
0.1491 0.0402 0.0379 0.15
0.6960 0.0329 0.0333 0.70
-0.1017 0.0461 0.0425 -0.10
-1.5006 0.0473 0.0459 -1.50
2.4991 0.0356 0.0391 2.50
-2.9996 0.0571 0.0628 -3.00
Table 8: 2000 observations and 200 simulations
1
1000 2
1
100
sin 7 . 0
100
1
0 . 3 , 5 . 2 , 5 . 1 , 0
1 . 0
7 . 0 , 15 . 0 , 1 . 0 , 1 . 0
3
3
2
1
3 2 1 0
1 2 1 0
,
_
t
t
t
x
t
x
t
x
b b b b
k
TR4/2000 NP3533 27
Student's t-distribution
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.1103 0.0397 0.0344 0.10
0.0984 0.0548 0.0568 0.10
0.1547 0.0746 0.0752 0.15
0.6856 0.0666 0.0598 0.70
-0.1060 0.0942 0.0848 -0.10
4.2912 0.6639 0.6037 4.10
-1.4998 0.0460 0.0540 -1.50
2.5087 0.0853 0.0882 2.00
-3.0118 0.0860 0.0931 -3.00
Table 9: 1000 observations and 200 simulations
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.1035 0.0236 0.0221 0.10
0.1005 0.0360 0.0347 0.10
0.1528 0.0488 0.0484 0.15
0.6924 0.0417 0.0404 0.70
-0.0998 0.0599 0.0569 -0.10
4.1854 0.4345 0.3988 4.10
-1.4971 0.0324 0.0360 -1.50
2.4986 0.0284 0.0306 2.00
-2.9977 0.0441 0.0494 -3.00
Table 10: 2000 observations and 200 simulations
TR4/2000 NP3533 28
GJR-GARCH
The GJR-GARCH(1,2) simulations used here had the following parameters:
The series shocks were taken from either a Gaussian distribution or a Student's t-distribution, with
the number of degrees of freedom ( ) df set to 4.10.
The GARCH model parameters are output in the descending order, , , , , ,
1 2 1 0
then df (if
present) followed by 3 , , 1 , K i b
i
Gaussian Distribution
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.1103 0.0410 0.0364 0.10
0.1367 0.0766 0.0774 0.15
0.2003 0.1185 0.1045 0.20
0.3805 0.1435 0.1270 0.40
0.1006 0.0766 0.0759 0.10
-1.4983 0.1010 0.0992 -1.50
2.4982 0.3288 0.3119 2.50
-3.0025 0.2560 0.2397 -3.00
Table 11: 400 observations and 300 simulations
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.1048 0.0269 0.0221 0.10
0.1451 0.0537 0.0502 0.15
0.1997 0.0752 0.0669 0.20
0.3936 0.0927 0.0784 0.40
0.0958 0.0511 0.0478 0.10
-1.5038 0.0379 0.0387 -1.50
2.4975 0.0645 0.0627 2.50
-2.9970 0.0677 0.0659 -3.00
Table 12: 1000 observations and 200 simulations
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.1018 0.0172 0.0152 0.10
0.1470 0.0387 0.0358 0.15
0.2001 0.0499 0.0476 0.20
0.3972 0.0602 0.0548 0.40
0.1007 0.0385 0.0340 0.10
-1.5016 0.0261 0.0264 -1.50
2.4998 0.0229 0.0224 2.50
-3.0000 0.0363 0.0361 -3.00
Table 13: 2000 observations and 200 simulations
1
1000 2
1
100
sin 7 . 0
100
1
0 . 3 , 5 . 2 , 5 . 1 , 0
1 . 0
4 . 0 , 2 . 0 , 15 . 0 , 1 . 0
3
3
2
1
3 2 1 0
1 2 1 0
,
_
t
t
t
x
t
x
t
x
b b b b
k
TR4/2000 NP3533 29
Student's t-distribution
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.1027 0.0266 0.0285 0.10
0.1392 0.0691 0.0813 0.15
0.2047 0.0932 0.1028 0.20
0.3904 0.0976 0.1131 0.40
0.1158 0.0655 0.1067 0.10
4.2716 0.6603 0.6395 4.10
-1.5013 0.0328 0.0336 -1.50
2.4977 0.0526 0.0564 2.00
-2.9989 0.0549 0.0599 -3.00
Table 14: 1000 observations and 200 simulations
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.1008 0.0178 0.0170 0.10
0.1469 0.0501 0.0531 0.15
0.2016 0.0716 0.0685 0.20
0.3940 0.0683 0.0663 0.60
0.1067 0.0489 0.0606 0.10
4.2076 0.4360 0.4040 4.10
-1.4982 0.0221 0.0231 -1.50
2.4994 0.0187 0.0188 2.00
-3.0003 0.0299 0.0314 -3.00
Table 15: 2000 observation and 200 simulations
TR4/2000 NP3533 30
EGARCH
The EGARCH(1,2) simulations used here had the following parameters:
The series shocks were taken from either a Gaussian distribution or a Student's t-distribution, with
the number of degrees of freedom ( ) df set to 4.10.
The GARCH model parameters are output in the descending order, , , , , , ,
1 2 1 2 1 0
then
df (if present) followed by 3 , , 1 , K i b
i
Gaussian Distribution
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.2786 0.1016 0.0974 0.30
-0.1965 0.0758 0.0738 -0.20
-0.2481 0.0958 0.0909 -0.25
0.0699 0.1186 0.1228 0.10
0.1346 0.1445 0.1285 0.15
0.3045 0.2213 0.1841 0.30
1.5181 0.1855 0.1928 1.50
2.5622 0.6413 0.6017 2.50
2.9430 0.4929 0.4626 3.00
Table 16: 400 observations and 300 simulations
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.2958 0.0709 0.0665 0.30
-0.1954 0.0471 0.0462 -0.20
-0.2533 0.0595 0.0571 -0.25
0.0848 0.0768 0.0789 0.15
0.1432 0.0850 0.0812 0.10
0.2914 0.1437 0.1247 0.30
1.4970 0.0747 0.0756 1.50
2.4969 0.1245 0.1231 2.50
3.0004 0.1301 0.1309 3.00
Table 17: 1000 observations and 200 simulations
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.2982 0.0452 0.0471 0.30
-0.1980 0.0317 0.0326 -0.20
-0.2540 0.0381 0.0401 -0.25
0.0932 0.0508 0.0533 0.15
0.1491 0.0591 0.0545 0.10
0.2967 0.0895 0.0870 0.30
1.5017 0.0528 0.0515 1.50
2.4999 0.0442 0.0431 2.50
2.9984 0.0748 0.0702 3.00
Table 18: 2000 observations and 200 simulations
1
1000 2
1
100
sin 7 . 0
100
1
0 . 3 , 5 . 2 , 5 . 1 , 0
, 3 . 0 , 15 . 0 , 1 . 0
, 25 . 0 , 2 . 0 , 3 . 0 , 3
3
1
2
3 2 1 0
1 2 1
2 1 0
,
_
+
t
t
t
x
t
x
t
x
b b b b
k
TR4/2000 NP3533 31
Student's t-distribution
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.2811 0.1022 0.0924 0.30
-0.2071 0.0628 0.0639 -0.20
-0.2452 0.0786 0.0794 -0.25
0.0865 0.0929 0.0903 0.10
0.1464 0.0932 0.0924 0.15
0.3223 0.1738 0.1526 0.30
4.3119 0.6819 0.4159 4.10
1.4983 0.0668 0.0738 1.50
2.4871 0.1142 0.1210 2.50
3.0094 0.1195 0.1267 3.00
Table 19: 1000 observations and 200 simulations
Estimated Value Estimated Standard Error Standard Error of Estimates Correct Values
0.2859 0.0702 0.0811 0.30
-0.2016 0.0426 0.0493 -0.20
-0.2483 0.0594 0.0706 -0.25
0.0926 0.0652 0.0657 0.10
0.1512 0.0633 0.0801 0.15
0.3154 0.1174 0.1283 0.30
4.2281 0.4348 0.3854 4.10
1.4942 0.0457 0.0539 1.50
2.4976 0.0413 0.0451 2.50
3.0001 0.0681 0.0734 3.00
Table 20: 2000 observations and 200 simulations
TR4/2000 NP3533 32
Conclusions
The simulation results presented in tables 1-20 indicate that the GARCH generation and estimation
Fortran 77 software performs as expected (The forecasting software has been tested elsewhere
[9]). It was found that reliable parameter estimates and associated standard errors could only be
achieved when at least 300 observations were included in the GARCH model. More difficult
GARCH models (those with more parameters to estimate or higher volatility memory) were found
to require even more observations to obtain consistent parameter estimates.
This report has discussed the current state of GARCH software that has been developed for Mark
20 of the NAG Fortran 77 Library. Since future modifications/improvements may take place it can
only be taken as a guide to the GARCH software that will be eventually included in the NAG
numerical libraries. Possible future improvements to the software could include the following:
Changing the GARCH estimation routines so that some of the model parameters can be
fixed (i.e., not estimated via maximum likelihood)
Other non-Gaussian shocks, such as the generalised error distribution, etc.
Other univariate GARCH models such GARCH-M etc.
Multivariate GARCH models
Generalising the GARCH model from regression-GARCH(p,q) to
ARMA(p1,q1)-GARCH(p2,q2)
Other possible modifications, concerned with language/user-interface, are as follows:
The inclusion of some modern Fortran features, such as memory allocation, to improve the
user-interface. Since Fortran 77 does not support memory allocation the current GARCH
software requires the user to calculate how much workspace is needed. The routines also
only allow up to 20 parameters to be estimated; this should be sufficient for most
requirements. The NAG C GARCH software, which uses internal memory allocation, does
not have these restrictions and is therefore easier to use.
The creation of Visual Basic wrappers which perform memory allocation and have optional
parameters etc. These could, for example, take the form of a GARCH Microsoft Excel add-
in which would have the advantage of interactive use and also shield users from the raw
Fortran 77 code.
The creation of a C++ class that contains all the GARCH functions, has optional/default
function parameters and also hides workspace, etc.
To conclude, it should be mentioned that the PC and workstation implementations of the NAG
numerical libraries permit software developers to call GARCH functions more easily than the
corresponding functions from time series packages. Although time series packages may offer the
advantage of interactive interfaces it is not easy (or computationally efficient) to call them
programmatically as a component of a larger system. The current NAG delivery mechanism is thus
well suited to software developers who want to incorporate individual GARCH routines into a new
application.
TR4/2000 NP3533 33
7 Acknowledgements
The author would like to thank Geoff Morgan for his help and suggestions, and also Anne
Trefethen and Neil Swindells for proof reading the manuscript.
All trademarks are acknowledged.
8 References
[1] NAG Ltd, The Fortran 77 Library Mark 20, NAG Ltd, Oxford, in preparation
[2] NAG Ltd, The NAG C Library Mark 6, NAG Ltd, Oxford, 2000.
[3] Engle R, Autoregressive Conditional Heteroskedasticity with Estimates of the Variance of
United Kingdom Inflation, Econometrica, 50, 987-1008, 1982
[4] Bollerslev T, Generalised Autoregressive Conditional Heteroskedasticity, Journal of
Econometrics, 31, 307-27, 1986
[5] Hamilton J, Time Series Analysis, Princeton University Press, 1994.
[6] Engle R, and Ng V, Measuring and Testing the Impact of News on Volatility, Journal of
Finance, 48, 1749-1777, 1993
[7] Glosten L, Jagannathan R, and Runkle D, Relationship between the Expected Value and the
Volatility of the Nominal Excess Return on Stocks, Journal of Finance, 48, 1779-1801, 1993.
[8] Silvey S D, Statistical Inference, Monographs on Applied Probability and Statistics, Chapman
and Hall, 1975
[9] NAG Ltd, The Fortran 77 Library Mark 20 GARCH stringent test programs, NAG Ltd,
Oxford, 2000