g05 Chapter Contents
g05 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_rand_garchGJR (g05pfc)

## 1  Purpose

nag_rand_garchGJR (g05pfc) generates a given number of terms of a GJR $\text{GARCH}\left(p,q\right)$ process (see Glosten et al. (1993)).

## 2  Specification

 #include #include
 void nag_rand_garchGJR (Nag_ErrorDistn dist, Integer num, Integer ip, Integer iq, const double theta[], double gamma, Integer df, double ht[], double et[], Nag_Boolean fcall, double r[], Integer lr, Integer state[], NagError *fail)

## 3  Description

A GJR $\text{GARCH}\left(p,q\right)$ 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 ${I}_{t}=1$ if ${\epsilon }_{t}<0$, ${I}_{t}=0$ if ${\epsilon }_{t}\ge 0$, and ${\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 negative shocks are to be enhanced.
One of the initialization functions nag_rand_init_repeatable (g05kfc) (for a repeatable sequence if computed sequentially) or nag_rand_init_nonrepeatable (g05kgc) (for a non-repeatable sequence) must be called prior to the first call to nag_rand_garchGJR (g05pfc).

## 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
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

## 5  Arguments

1:     distNag_ErrorDistnInput
On entry: the type of distribution to use for ${\epsilon }_{t}$.
${\mathbf{dist}}=\mathrm{Nag_NormalDistn}$
A Normal distribution is used.
${\mathbf{dist}}=\mathrm{Nag_Tdistn}$
A Student's $t$-distribution is used.
Constraint: ${\mathbf{dist}}=\mathrm{Nag_NormalDistn}$ or $\mathrm{Nag_Tdistn}$.
2:     numIntegerInput
On entry: $T$, the number of terms in the sequence.
Constraint: ${\mathbf{num}}>0$.
3:     ipIntegerInput
On entry: the number of coefficients, ${\beta }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,p$.
Constraint: ${\mathbf{ip}}\ge 0$.
4:     iqIntegerInput
On entry: the number of coefficients, ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
Constraint: ${\mathbf{iq}}\ge 1$.
5:     theta[${\mathbf{iq}}+{\mathbf{ip}}+1$]const doubleInput
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}-1\right]<1.0$;
• ${\mathbf{theta}}\left[\mathit{i}-1\right]\ge 0.0$, for $i=1$ and $i={\mathbf{iq}}+2,\dots ,{\mathbf{iq}}+{\mathbf{ip}}+1$.
On entry: the asymmetry parameter $\gamma$ for the $\text{GARCH}\left(p,q\right)$ sequence.
Constraint: ${\mathbf{gamma}}+{\mathbf{theta}}\left[\mathit{i}-1\right]\ge 0.0$, for $\mathit{i}=2,3,\dots ,{\mathbf{iq}}+1$.
7:     dfIntegerInput
On entry: the number of degrees of freedom for the Student's $t$-distribution.
If ${\mathbf{dist}}=\mathrm{Nag_NormalDistn}$, df is not referenced.
Constraint: if ${\mathbf{dist}}=\mathrm{Nag_Tdistn}$, ${\mathbf{df}}>2$.
8:     ht[num]doubleOutput
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:     et[num]doubleOutput
On exit: the observations ${\epsilon }_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$, for the $\text{GARCH}\left(p,q\right)$ sequence.
10:   fcallNag_BooleanInput
On entry: if ${\mathbf{fcall}}=\mathrm{Nag_TRUE}$, a new sequence is to be generated, otherwise a given sequence is to be continued using the information in r.
11:   r[lr]doubleInput/Output
On entry: the array contains information required to continue a sequence if ${\mathbf{fcall}}=\mathrm{Nag_FALSE}$.
On exit: contains information that can be used in a subsequent call of nag_rand_garchGJR (g05pfc), with ${\mathbf{fcall}}=\mathrm{Nag_FALSE}$.
12:   lrIntegerInput
On entry: the dimension of the array r.
Constraint: ${\mathbf{lr}}\ge 2×\left({\mathbf{ip}}+{\mathbf{iq}}+2\right)$.
13:   state[$\mathit{dim}$]IntegerCommunication Array
Note: the dimension, $\mathit{dim}$, of this array is dictated by the requirements of associated functions that must have been previously called. This array MUST be the same array passed as argument state in the previous call to nag_rand_init_repeatable (g05kfc) or nag_rand_init_nonrepeatable (g05kgc).
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:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_INT
On entry, ${\mathbf{df}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{df}}\ge 3$.
On entry, ${\mathbf{ip}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ip}}\ge 0$.
On entry, ${\mathbf{iq}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{iq}}\ge 1$.
On entry, lr is not large enough, ${\mathbf{lr}}=⟨\mathit{\text{value}}⟩$: minimum length required $\text{}=⟨\mathit{\text{value}}⟩$.
On entry, ${\mathbf{num}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{num}}\ge 0$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_INVALID_STATE
On entry, state vector has been corrupted or not initialized.
NE_PREV_CALL
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}}⟩$.
NE_REAL_2
On entry, ${\mathbf{theta}}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$ and $\gamma =⟨\mathit{\text{value}}⟩$.
Constraint: ${\alpha }_{i}+\gamma \ge 0$.
NE_REAL_ARRAY
On entry, sum of ${\mathbf{theta}}\left[i\right]=⟨\mathit{\text{value}}⟩$.
Constraint: sum of ${\mathbf{theta}}\left[\mathit{i}\right]$, for $\mathit{i}=1,2,\dots ,{\mathbf{ip}}+{\mathbf{iq}}$ is $\text{}<1.0$.
On entry, ${\mathbf{theta}}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{theta}}\left[i\right]\ge 0.0$.

Not applicable.

## 8  Parallelism and Performance

nag_rand_garchGJR (g05pfc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the Users' Note for your implementation for any additional implementation-specific information.

None.

## 10  Example

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

### 10.1  Program Text

Program Text (g05pfce.c)

None.

### 10.3  Program Results

Program Results (g05pfce.r)