# NAG FL Interfaceg05pdf (times_​garch_​asym1)

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine g05pdf ( dist, num, ip, iq, df, ht, et, r, lr,
 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
#include <nag.h>
 void g05pdf_ (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)
The routine may be called by the names g05pdf or nagf_rand_times_garch_asym1.

## 3Description

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.

## 4References

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

## 5Arguments

1: $\mathbf{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: $\mathbf{num}$Integer Input
On entry: $T$, the number of terms in the sequence.
Constraint: ${\mathbf{num}}\ge 0$.
3: $\mathbf{ip}$Integer Input
On entry: the number of coefficients, ${\beta }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,p$.
Constraint: ${\mathbf{ip}}\ge 0$.
4: $\mathbf{iq}$Integer Input
On entry: the number of coefficients, ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
Constraint: ${\mathbf{iq}}\ge 1$.
5: $\mathbf{theta}\left({\mathbf{iq}}+{\mathbf{ip}}+1\right)$Real (Kind=nag_wp) array Input
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: $\mathbf{gamma}$Real (Kind=nag_wp) Input
On entry: the asymmetry parameter $\gamma$ for the $\text{GARCH}\left(p,q\right)$ sequence.
7: $\mathbf{df}$Integer Input
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: $\mathbf{ht}\left({\mathbf{num}}\right)$Real (Kind=nag_wp) array Output
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: $\mathbf{et}\left({\mathbf{num}}\right)$Real (Kind=nag_wp) array Output
On exit: the observations ${\epsilon }_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$, for the $\text{GARCH}\left(p,q\right)$ sequence.
10: $\mathbf{fcall}$Logical Input
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: $\mathbf{r}\left({\mathbf{lr}}\right)$Real (Kind=nag_wp) array Input/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: $\mathbf{lr}$Integer Input
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: $\mathbf{state}\left(*\right)$Integer array Communication 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: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{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:
${\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 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

Not applicable.

## 8Parallelism 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.

## 10Example

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.1Program Text

Program Text (g05pdfe.f90)

### 10.2Program Data

Program Data (g05pdfe.d)

### 10.3Program Results

Program Results (g05pdfe.r)