G05 Chapter Contents
G05 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG05PDF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

G05PDF generates a given number of terms of a type I $\text{AGARCH}\left(p,q\right)$ process (see Engle and Ng (1993)).

## 2  Specification

 SUBROUTINE G05PDF ( DIST, NUM, IP, IQ, THETA, GAMMA, DF, HT, ET, FCALL, R, LR, STATE, IFAIL)
 INTEGER NUM, IP, IQ, DF, LR, STATE(*), IFAIL REAL (KIND=nag_wp) THETA(IQ+IP+1), GAMMA, HT(NUM), ET(NUM), R(LR) LOGICAL FCALL CHARACTER(1) DIST

## 3  Description

A type I $\text{AGARCH}\left(p,q\right)$ process can be represented by:
 $ht = α0 + ∑i=1q αi εt-i + γ 2 + ∑i=1p βi ht-i , t=1,2,…,T ;$
where ${\epsilon }_{t}\mid {\psi }_{t-1}=N\left(0,{h}_{t}\right)$ or ${\epsilon }_{t}\mid {\psi }_{t-1}={S}_{t}\left(\mathit{df},{h}_{t}\right)$. Here ${S}_{t}$ is a standardized Student's $t$-distribution with $\mathit{df}$ degrees of freedom and variance ${h}_{t}$, $T$ is the number of observations in the sequence, ${\epsilon }_{t}$ is the observed value of the $\text{GARCH}\left(p,q\right)$ process at time $t$, ${h}_{t}$ is the conditional variance at time $t$, and ${\psi }_{t}$ the set of all information up to time $t$. Symmetric GARCH sequences are generated when $\gamma$ is zero, otherwise asymmetric GARCH sequences are generated with $\gamma$ specifying the amount by which positive (or 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 G05PDF.

## 4  References

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
Hamilton J (1994) Time Series Analysis Princeton University Press

## 5  Parameters

1:     $\mathrm{DIST}$ – CHARACTER(1)Input
On entry: the type of distribution to use for ${\epsilon }_{t}$.
${\mathbf{DIST}}=\text{'N'}$
A Normal distribution is used.
${\mathbf{DIST}}=\text{'T'}$
A Student's $t$-distribution is used.
Constraint: ${\mathbf{DIST}}=\text{'N'}$ or $\text{'T'}$.
2:     $\mathrm{NUM}$ – INTEGERInput
On entry: $T$, the number of terms in the sequence.
Constraint: ${\mathbf{NUM}}\ge 0$.
3:     $\mathrm{IP}$ – INTEGERInput
On entry: the number of coefficients, ${\beta }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,p$.
Constraint: ${\mathbf{IP}}\ge 0$.
4:     $\mathrm{IQ}$ – INTEGERInput
On entry: the number of coefficients, ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
Constraint: ${\mathbf{IQ}}\ge 1$.
5:     $\mathrm{THETA}\left({\mathbf{IQ}}+{\mathbf{IP}}+1\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: the first element must contain the coefficient ${\alpha }_{o}$, the next IQ elements must contain the coefficients ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$. The remaining IP elements must contain the coefficients ${\beta }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,p$.
Constraints:
• $\sum _{\mathit{i}=2}^{{\mathbf{IQ}}+{\mathbf{IP}}+1}{\mathbf{THETA}}\left(\mathit{i}\right)<1.0$;
• ${\mathbf{THETA}}\left(\mathit{i}\right)\ge 0.0$, for $\mathit{i}=2,3,\dots ,{\mathbf{IP}}+{\mathbf{IQ}}+1$.
6:     $\mathrm{GAMMA}$ – REAL (KIND=nag_wp)Input
On entry: the asymmetry parameter $\gamma$ for the $\text{GARCH}\left(p,q\right)$ sequence.
7:     $\mathrm{DF}$ – INTEGERInput
On entry: the number of degrees of freedom for the Student's $t$-distribution.
If ${\mathbf{DIST}}=\text{'N'}$, DF is not referenced.
Constraint: if ${\mathbf{DIST}}=\text{'T'}$, ${\mathbf{DF}}>2$.
8:     $\mathrm{HT}\left({\mathbf{NUM}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: the conditional variances ${h}_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$, for the $\text{GARCH}\left(p,q\right)$ sequence.
9:     $\mathrm{ET}\left({\mathbf{NUM}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: the observations ${\epsilon }_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$, for the $\text{GARCH}\left(p,q\right)$ sequence.
10:   $\mathrm{FCALL}$ – LOGICALInput
On entry: if ${\mathbf{FCALL}}=\mathrm{.TRUE.}$, a new sequence is to be generated, otherwise a given sequence is to be continued using the information in R.
11:   $\mathrm{R}\left({\mathbf{LR}}\right)$ – REAL (KIND=nag_wp) arrayInput/Output
On entry: the array contains information required to continue a sequence if ${\mathbf{FCALL}}=\mathrm{.FALSE.}$.
On exit: contains information that can be used in a subsequent call of G05PDF, with ${\mathbf{FCALL}}=\mathrm{.FALSE.}$.
12:   $\mathrm{LR}$ – INTEGERInput
On entry: the dimension of the array R as declared in the (sub)program from which G05PDF is called.
Constraint: ${\mathbf{LR}}\ge 2×\left({\mathbf{IP}}+{\mathbf{IQ}}+2\right)$.
13:   $\mathrm{STATE}\left(*\right)$ – 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:   $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ 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 parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
On entry, DIST is not valid: ${\mathbf{DIST}}=〈\mathit{\text{value}}〉$.
${\mathbf{IFAIL}}=2$
On entry, ${\mathbf{NUM}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{NUM}}\ge 0$.
${\mathbf{IFAIL}}=3$
On entry, ${\mathbf{IP}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{IP}}\ge 0$.
${\mathbf{IFAIL}}=4$
On entry, ${\mathbf{IQ}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{IQ}}\ge 1$.
${\mathbf{IFAIL}}=5$
On entry, ${\mathbf{THETA}}\left(〈\mathit{\text{value}}〉\right)=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{THETA}}\left(i\right)\ge 0.0$.
${\mathbf{IFAIL}}=7$
On entry, ${\mathbf{DF}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{DF}}\ge 3$.
${\mathbf{IFAIL}}=11$
IP or IQ is not the same as when R was set up in a previous call.
Previous value of ${\mathbf{IP}}=〈\mathit{\text{value}}〉$ and ${\mathbf{IP}}=〈\mathit{\text{value}}〉$.
Previous value of ${\mathbf{IQ}}=〈\mathit{\text{value}}〉$ and ${\mathbf{IQ}}=〈\mathit{\text{value}}〉$.
${\mathbf{IFAIL}}=12$
On entry, LR is not large enough, ${\mathbf{LR}}=〈\mathit{\text{value}}〉$: minimum length required $\text{}=〈\mathit{\text{value}}〉$.
${\mathbf{IFAIL}}=13$
On entry, STATE vector has been corrupted or not initialized.
${\mathbf{IFAIL}}=51$
On entry, sum of ${\mathbf{THETA}}\left(\mathit{i}\right)$, for $\mathit{i}=2,3,\dots ,{\mathbf{IP}}+{\mathbf{IQ}}+1$ is $\text{}\ge 1.0$: $\mathrm{sum}=〈\mathit{\text{value}}〉$.
${\mathbf{IFAIL}}=-99$
See Section 3.8 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

Not applicable.

## 8  Parallelism and Performance

G05PDF 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.

None.

## 10  Example

This example first calls G05KFF to initialize a base generator then calls G05PDF to generate two realizations, each consisting of ten observations, from a symmetric $\mathrm{GARCH}\left(1,1\right)$ model.

### 10.1  Program Text

Program Text (g05pdfe.f90)

### 10.2  Program Data

Program Data (g05pdfe.d)

### 10.3  Program Results

Program Results (g05pdfe.r)