NAG Library Routine Document

g05pff (times_garch_gjr)


g05pff generates a given number of terms of a GJR GARCHp,q process (see Glosten et al. (1993)).


Fortran Interface
Subroutine g05pff ( dist, num, ip, iq, theta, gamma, df, ht, et, fcall, r, lr, state, ifail)
Integer, Intent (In):: num, ip, iq, df, lr
Integer, Intent (Inout):: state(*), ifail
Real (Kind=nag_wp), Intent (In):: theta(iq+ip+1), gamma
Real (Kind=nag_wp), Intent (Inout):: r(lr)
Real (Kind=nag_wp), Intent (Out):: ht(num), et(num)
Logical, Intent (In):: fcall
Character (1), Intent (In):: dist
C Header Interface
#include <nagmk26.h>
void  g05pff_ (const char *dist, const Integer *num, const Integer *ip, const Integer *iq, const double theta[], const double *gamma, const Integer *df, double ht[], double et[], const logical *fcall, double r[], const Integer *lr, Integer state[], Integer *ifail, const Charlen length_dist)


A GJR GARCHp,q process is represented by:
ht = α0 + i=1q αi + γ It-i ε t-i 2 + i=1 p βi ht-i ,   t=1,2,,T ;  
where It=1 if εt<0, It=0 if εt0, and εtψt-1=N0,ht or εtψt-1=Stdf,ht. Here St is a standardized Student's t-distribution with df degrees of freedom and variance ht, T is the number of observations in the sequence, εt is the observed value of the GARCHp,q process at time t, ht is the conditional variance at time t, and ψt the set of all information up to time t. Symmetric GARCH sequences are generated when γ is zero, otherwise asymmetric GARCH sequences are generated with γ specifying the amount by which negative shocks are to be enhanced.
One of the initialization routines g05kff (for a repeatable sequence if computed sequentially) or g05kgf (for a non-repeatable sequence) must be called prior to the first call to g05pff.


Bollerslev T (1986) Generalised autoregressive conditional heteroskedasticity Journal of Econometrics 31 307–327
Engle R (1982) Autoregressive conditional heteroskedasticity with estimates of the variance of United Kingdom inflation Econometrica 50 987–1008
Engle R and Ng V (1993) Measuring and testing the impact of news on volatility Journal of Finance 48 1749–1777
Glosten L, Jagannathan R and Runkle D (1993) Relationship between the expected value and the volatility of nominal excess return on stocks Journal of Finance 48 1779–1801
Hamilton J (1994) Time Series Analysis Princeton University Press


1:     dist – Character(1)Input
On entry: the type of distribution to use for εt.
A Normal distribution is used.
A Student's t-distribution is used.
Constraint: dist='N' or 'T'.
2:     num – IntegerInput
On entry: T, the number of terms in the sequence.
Constraint: num>0.
3:     ip – IntegerInput
On entry: the number of coefficients, βi, for i=1,2,,p.
Constraint: ip0.
4:     iq – IntegerInput
On entry: the number of coefficients, αi, for i=1,2,,q.
Constraint: iq1.
5:     thetaiq+ip+1 – Real (Kind=nag_wp) arrayInput
On entry: the first element must contain the coefficient αo, the next iq elements must contain the coefficients αi, for i=1,2,,q. The remaining ip elements must contain the coefficients βj, for j=1,2,,p.
  • i=2 iq+ip+1 thetai<1.0;
  • thetai0.0, for i=1 and i=iq+2,,iq+ip+1.
6:     gamma – Real (Kind=nag_wp)Input
On entry: the asymmetry parameter γ for the GARCHp,q sequence.
Constraint: gamma+thetai0.0, for i=2,3,,iq+1.
7:     df – IntegerInput
On entry: the number of degrees of freedom for the Student's t-distribution.
If dist='N', df is not referenced.
Constraint: if dist='T', df>2.
8:     htnum – Real (Kind=nag_wp) arrayOutput
On exit: the conditional variances ht, for t=1,2,,T, for the GARCHp,q sequence.
9:     etnum – Real (Kind=nag_wp) arrayOutput
On exit: the observations εt, for t=1,2,,T, for the GARCHp,q sequence.
10:   fcall – LogicalInput
On entry: if fcall=.TRUE., a new sequence is to be generated, otherwise a given sequence is to be continued using the information in r.
11:   rlr – Real (Kind=nag_wp) arrayInput/Output
On entry: the array contains information required to continue a sequence if fcall=.FALSE..
On exit: contains information that can be used in a subsequent call of g05pff, with fcall=.FALSE..
12:   lr – IntegerInput
On entry: the dimension of the array r as declared in the (sub)program from which g05pff is called.
Constraint: lr2×ip+iq+2.
13:   state* – Integer arrayCommunication Array
Note: the actual argument supplied must be the array state supplied to the initialization routines g05kff or g05kgf.
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
14:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 or 1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, dist is not valid: dist=value.
On entry, num=value.
Constraint: num0.
On entry, ip=value.
Constraint: ip0.
On entry, iq=value.
Constraint: iq1.
On entry, thetavalue=value and γ=value.
Constraint: αi+γ0.
On entry, df=value.
Constraint: df3.
ip or iq is not the same as when r was set up in a previous call.
Previous value of ip=value and ip=value.
Previous value of iq=value and iq=value.
On entry, lr is not large enough, lr=value: minimum length required =value.
On entry, state vector has been corrupted or not initialized.
On entry, thetavalue=value.
Constraint: thetai0.0.
On entry, sum of thetai=value.
Constraint: sum of thetai, for i=1,2,,ip+iq is <1.0.
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.


Not applicable.

Parallelism and Performance

g05pff is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

Further Comments



This example first calls g05kff to initialize a base generator then calls g05pff to generate two realizations, each consisting of ten observations, from a GJR GARCH1,1 model.

Program Text

Program Text (g05pffe.f90)

Program Data

Program Data (g05pffe.d)

Program Results

Program Results (g05pffe.r)