G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG13FEF

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

G13FEF estimates the parameters of a univariate regression-GJR $\text{GARCH}\left(p,q\right)$ process (see Glosten et al. (1993)).

## 2  Specification

 SUBROUTINE G13FEF ( DIST, YT, X, LDX, NUM, IP, IQ, NREG, MN, NPAR, THETA, SE, SC, COVR, LDCOVR, HP, ET, HT, LGF, COPTS, MAXIT, TOL, WORK, LWORK, IFAIL)
 INTEGER LDX, NUM, IP, IQ, NREG, MN, NPAR, LDCOVR, MAXIT, LWORK, IFAIL REAL (KIND=nag_wp) YT(NUM), X(LDX,*), THETA(NPAR), SE(NPAR), SC(NPAR), COVR(LDCOVR,NPAR), HP, ET(NUM), HT(NUM), LGF, TOL, WORK(LWORK) LOGICAL COPTS(2) CHARACTER(1) DIST

## 3  Description

A univariate regression-GJR $\text{GARCH}\left(p,q\right)$ process, with $q$ coefficients ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$, $p$ coefficients ${\beta }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,p$, and $k$ linear regression coefficients ${b}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,k$, can be represented by:
 $yt = bo + xtT b + εt$ (1)
 $ht = α0 + ∑ i=1 q αi + γ It-i ε t-i2 + ∑ i=1 p βi ht-i , t=1,2,…,T$ (2)
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 terms in the sequence, ${y}_{t}$ denotes the endogenous variables, ${x}_{t}$ the exogenous variables, ${b}_{o}$ the regression mean, $b$ the regression coefficients, ${\epsilon }_{t}$ the residuals, ${h}_{t}$ is the conditional variance, and ${\psi }_{t}$ the set of all information up to time $t$.
G13FEF provides an estimate for $\stackrel{^}{\theta }$, the parameter vector $\theta =\left({b}_{o},{b}^{\mathrm{T}},{\omega }^{\mathrm{T}}\right)$ where ${b}^{\mathrm{T}}=\left({b}_{1},\dots ,{b}_{k}\right)$, ${\omega }^{\mathrm{T}}=\left({\alpha }_{0},{\alpha }_{1},\dots ,{\alpha }_{q},{\beta }_{1},\dots ,{\beta }_{p},\gamma \right)$ when ${\mathbf{DIST}}=\text{'N'}$ and ${\omega }^{\mathrm{T}}=\left({\alpha }_{0},{\alpha }_{1},\dots ,{\alpha }_{q},{\beta }_{1},\dots ,{\beta }_{p},\gamma ,\mathit{df}\right)$ when ${\mathbf{DIST}}=\text{'T'}$.
MN, NREG can be used to simplify the $\text{GARCH}\left(p,q\right)$ expression in (1) as follows:
No Regression and No Mean
• ${y}_{t}={\epsilon }_{t}$,
• ${\mathbf{MN}}=0$,
• ${\mathbf{NREG}}=0$ and
• $\theta$ is a $\left(p+q+2\right)$ vector when ${\mathbf{DIST}}=\text{'N'}$, and a $\left(p+q+3\right)$ vector when ${\mathbf{DIST}}=\text{'T'}$.
No Regression
• ${y}_{t}={b}_{o}+{\epsilon }_{t}$,
• ${\mathbf{MN}}=1$,
• ${\mathbf{NREG}}=0$ and
• $\theta$ is a $\left(p+q+3\right)$ vector when ${\mathbf{DIST}}=\text{'N'}$, and a $\left(p+q+4\right)$ vector when ${\mathbf{DIST}}=\text{'T'}$.
Note:  if the ${y}_{t}=\mu +{\epsilon }_{t}$, where $\mu$ is known (not to be estimated by G13FEF) then (1) can be written as ${y}_{t}^{\mu }={\epsilon }_{t}$, where ${y}_{t}^{\mu }={y}_{t}-\mu$. This corresponds to the case No Regression and No Mean, with ${y}_{t}$ replaced by ${y}_{t}-\mu$.
No Mean
• ${y}_{t}={x}_{t}^{\mathrm{T}}b+{\epsilon }_{t}$,
• ${\mathbf{MN}}=0$,
• ${\mathbf{NREG}}=k$ and
• $\theta$ is a $\left(p+q+k+2\right)$ vector when ${\mathbf{DIST}}=\text{'N'}$, and a $\left(p+q+k+3\right)$ vector when ${\mathbf{DIST}}=\text{'T'}$.
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  Parameters

1:     DIST – CHARACTER(1)Input
On entry: the type of distribution to use for ${e}_{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:     YT(NUM) – REAL (KIND=nag_wp) arrayInput
On entry: the sequence of observations, ${y}_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$.
3:     X(LDX,$*$) – REAL (KIND=nag_wp) arrayInput
Note: the second dimension of the array X must be at least ${\mathbf{NREG}}$.
On entry: row $\mathit{t}$ of X must contain the time dependent exogenous vector ${x}_{\mathit{t}}$, where ${x}_{\mathit{t}}^{\mathrm{T}}=\left({x}_{\mathit{t}}^{1},\dots ,{x}_{\mathit{t}}^{k}\right)$, for $\mathit{t}=1,2,\dots ,T$.
4:     LDX – INTEGERInput
On entry: the first dimension of the array X as declared in the (sub)program from which G13FEF is called.
Constraint: ${\mathbf{LDX}}\ge {\mathbf{NUM}}$.
5:     NUM – INTEGERInput
On entry: $T$, the number of terms in the sequence.
Constraints:
• ${\mathbf{NUM}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{IP}},{\mathbf{IQ}}\right)$;
• ${\mathbf{NUM}}\ge {\mathbf{NREG}}+{\mathbf{MN}}$.
6:     IP – INTEGERInput
On entry: the number of coefficients, ${\beta }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,p$.
Constraint: ${\mathbf{IP}}\ge 0$ (see also NPAR).
7:     IQ – INTEGERInput
On entry: the number of coefficients, ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
Constraint: ${\mathbf{IQ}}\ge 1$ (see also NPAR).
8:     NREG – INTEGERInput
On entry: $k$, the number of regression coefficients.
Constraint: ${\mathbf{NREG}}\ge 0$ (see also NPAR).
9:     MN – INTEGERInput
On entry: if ${\mathbf{MN}}=1$, the mean term ${b}_{0}$ will be included in the model.
Constraint: ${\mathbf{MN}}=0$ or $1$.
10:   NPAR – INTEGERInput
On entry: the number of parameters to be included in the model. ${\mathbf{NPAR}}=2+{\mathbf{IQ}}+{\mathbf{IP}}+{\mathbf{MN}}+{\mathbf{NREG}}$ when ${\mathbf{DIST}}=\text{'N'}$ and ${\mathbf{NPAR}}=3+{\mathbf{IQ}}+{\mathbf{IP}}+{\mathbf{MN}}+{\mathbf{NREG}}$ when ${\mathbf{DIST}}=\text{'T'}$.
Constraint: ${\mathbf{NPAR}}<20$.
11:   THETA(NPAR) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the initial parameter estimates for the vector $\theta$.
The first element must contain the coefficient ${\alpha }_{o}$ and the next IQ elements contain the coefficients ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
The next IP elements must contain the coefficients ${\beta }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,p$.
The next element must contain the asymmetry parameter $\gamma$.
If ${\mathbf{DIST}}=\text{'T'}$, the next element contains $\mathit{df}$, the number of degrees of freedom of the Student's $t$-distribution.
If ${\mathbf{MN}}=1$, the next element must contain the mean term ${b}_{o}$.
If ${\mathbf{COPTS}}\left(2\right)=\mathrm{.FALSE.}$, the remaining NREG elements are taken as initial estimates of the linear regression coefficients ${b}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,k$.
On exit: the estimated values $\stackrel{^}{\theta }$ for the vector $\theta$.
The first element contains the coefficient ${\alpha }_{o}$, the next IQ elements contain the coefficients ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
The next IP elements are the moving average coefficients ${\beta }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,p$.
The next element contains the estimate for the asymmetry parameter $\gamma$.
If ${\mathbf{DIST}}=\text{'T'}$, the next element contains an estimate for $\mathit{df}$, the number of degrees of freedom of the Student's $t$-distribution.
If ${\mathbf{MN}}=1$, the next element contains an estimate for the mean term ${b}_{o}$.
The final NREG elements are the estimated linear regression coefficients ${b}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,k$.
12:   SE(NPAR) – REAL (KIND=nag_wp) arrayOutput
On exit: the standard errors for $\stackrel{^}{\theta }$.
The first element contains the standard error for ${\alpha }_{o}$ and the next IQ elements contain the standard errors for ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
The next IP elements are the standard errors for ${\beta }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,p$.
The next element contains the standard error for $\gamma$.
If ${\mathbf{DIST}}=\text{'T'}$, the next element contains the standard error for $\mathit{df}$, the number of degrees of freedom of the Student's $t$-distribution.
If ${\mathbf{MN}}=1$, the next element contains the standard error for ${b}_{o}$.
The final NREG elements are the standard errors for ${b}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,k$.
13:   SC(NPAR) – REAL (KIND=nag_wp) arrayOutput
On exit: the scores for $\stackrel{^}{\theta }$.
The first element contains the score for ${\alpha }_{o}$, the next IQ elements contain the scores for ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
The next IP elements are the score for ${\beta }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,p$.
The next element contains the score for $\gamma$.
If ${\mathbf{DIST}}=\text{'T'}$, the next element contains the score for $\mathit{df}$, the number of degrees of freedom of the Student's $t$-distribution.
If ${\mathbf{MN}}=1$, the next element contains the score for ${b}_{o}$.
The final NREG elements are the scores for ${b}_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,k$.
14:   COVR(LDCOVR,NPAR) – REAL (KIND=nag_wp) arrayOutput
On exit: the covariance matrix of the parameter estimates $\stackrel{^}{\theta }$, that is the inverse of the Fisher Information Matrix.
15:   LDCOVR – INTEGERInput
On entry: the first dimension of the array COVR as declared in the (sub)program from which G13FEF is called.
Constraint: ${\mathbf{LDCOVR}}\ge {\mathbf{NPAR}}$.
16:   HP – REAL (KIND=nag_wp)Input/Output
On entry: if ${\mathbf{COPTS}}\left(2\right)=\mathrm{.FALSE.}$, HP is the value to be used for the pre-observed conditional variance; otherwise HP is not referenced.
On exit: if ${\mathbf{COPTS}}\left(2\right)=\mathrm{.TRUE.}$, HP is the estimated value of the pre-observed conditional variance.
17:   ET(NUM) – REAL (KIND=nag_wp) arrayOutput
On exit: the estimated residuals, ${\epsilon }_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$.
18:   HT(NUM) – REAL (KIND=nag_wp) arrayOutput
On exit: the estimated conditional variances, ${h}_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$.
19:   LGF – REAL (KIND=nag_wp)Output
On exit: the value of the log-likelihood function at $\stackrel{^}{\theta }$.
20:   COPTS($2$) – LOGICAL arrayInput
On entry: the options to be used by G13FEF.
${\mathbf{COPTS}}\left(1\right)=\mathrm{.TRUE.}$
Stationary conditions are enforced, otherwise they are not.
${\mathbf{COPTS}}\left(2\right)=\mathrm{.TRUE.}$
The routine provides initial parameter estimates of the regression terms, otherwise these are to be provided by you.
21:   MAXIT – INTEGERInput
On entry: the maximum number of iterations to be used by the optimization routine when estimating the $\text{GARCH}\left(p,q\right)$ parameters. If MAXIT is set to $0$, the standard errors, score vector and variance-covariance are calculated for the input value of $\theta$ in THETA; however the value of $\theta$ is not updated.
Constraint: ${\mathbf{MAXIT}}\ge 0$.
22:   TOL – REAL (KIND=nag_wp)Input
On entry: the tolerance to be used by the optimization routine when estimating the $\text{GARCH}\left(p,q\right)$ parameters.
23:   WORK(LWORK) – REAL (KIND=nag_wp) arrayWorkspace
24:   LWORK – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which G13FEF is called.
Constraint: ${\mathbf{LWORK}}\ge \left({\mathbf{NREG}}+3\right)×{\mathbf{NUM}}+{\mathbf{NPAR}}+403$.
25:   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, because for this routine the values of the output parameters may be useful even if ${\mathbf{IFAIL}}\ne {\mathbf{0}}$ on exit, the recommended value is $-1$. When the value $-\mathbf{1}\text{​ or ​}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).
Note: G13FEF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{NREG}}<0$, or ${\mathbf{MN}}>1$, or ${\mathbf{MN}}<0$, or ${\mathbf{IQ}}<1$, or ${\mathbf{IP}}<0$, or ${\mathbf{NPAR}}\ge 20$, or NPAR has an invalid value, or ${\mathbf{LDCOVR}}<{\mathbf{NPAR}}$, or ${\mathbf{LDX}}<{\mathbf{NUM}}$, or ${\mathbf{DIST}}\ne \text{'N'}$, or ${\mathbf{DIST}}\ne \text{'T'}$, or ${\mathbf{MAXIT}}<0$, or ${\mathbf{NUM}}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{IP}},{\mathbf{IQ}}\right)$, or ${\mathbf{NUM}}<{\mathbf{NREG}}+{\mathbf{MN}}$.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{LWORK}}<\left({\mathbf{NREG}}+3\right)×{\mathbf{NUM}}+{\mathbf{NPAR}}+403$.
${\mathbf{IFAIL}}=3$
The matrix $X$ is not full rank.
${\mathbf{IFAIL}}=4$
The information matrix is not positive definite.
${\mathbf{IFAIL}}=5$
The maximum number of iterations has been reached.
${\mathbf{IFAIL}}=6$
The log-likelihood cannot be optimized any further.
${\mathbf{IFAIL}}=7$
No feasible model parameters could be found.

Not applicable.

None.

## 9  Example

This example fits a $\text{GARCH}\left(1,1\right)$ model with Student's $t$-distributed residuals to some simulated data.
The process parameter estimates, $\stackrel{^}{\theta }$, are obtained using G13FEF, and a four step ahead volatility estimate is computed using G13FFF.
The data was simulated using G05PFF.

### 9.1  Program Text

Program Text (g13fefe.f90)

### 9.2  Program Data

Program Data (g13fefe.d)

### 9.3  Program Results

Program Results (g13fefe.r)