G13FGF (PDF version)
G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG13FGF

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

G13FGF estimates the parameters of a univariate regression-exponential $\text{GARCH}\left(p,q\right)$ process (see Engle and Ng (1993)).

## 2  Specification

 SUBROUTINE G13FGF ( 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 CHARACTER(1) DIST

## 3  Description

A univariate regression-exponential $\text{GARCH}\left(p,q\right)$ process, with $q$ coefficients ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$, $q$ coefficients ${\varphi }_{\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 lnht = α0+ ∑ i=1 q αi zt-i + ∑ i=1 q ϕi zt-i - E zt-i + ∑ i=1 p βi ln ht-i , t=1,2,…,T$ (1)
where ${z}_{t}=\frac{{\epsilon }_{t}}{\sqrt{{h}_{t}}}$, $E\left[\left|{z}_{t-i}\right|\right]$ denotes the expected value of $\left|{z}_{t-i}\right|$ 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}$ the conditional variance, $\mathit{df}$ the number of degrees of freedom of the Student's $t$-distribution, and ${\psi }_{t}$ the set of all information up to time $t$.
G13FGF provides an estimate $\stackrel{^}{\theta }$, for the 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},{\varphi }_{1},\dots ,{\varphi }_{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},{\varphi }_{1},\dots ,{\varphi }_{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(2×q+p+1\right)$ vector when ${\mathbf{DIST}}=\text{'N'}$, and a $\left(2×q+p+2\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(2×q+p+2\right)$ vector when ${\mathbf{DIST}}=\text{'N'}$ and a $\left(2×q+p+3\right)$ vector, when ${\mathbf{DIST}}=\text{'T'}$.
Note:  if the ${y}_{t}=\mu +{\epsilon }_{t}$, where $\mu$ is known (not to be estimated by G13FGF) 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(2×q+p+1+k\right)$ vector when ${\mathbf{DIST}}=\text{'N'}$ and a $\left(2×q+p+2+k\right)$ vector, when ${\mathbf{DIST}}=\text{'T'}$.

## 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  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 G13FGF 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}}=1+2×{\mathbf{IQ}}+{\mathbf{IP}}+{\mathbf{MN}}+{\mathbf{NREG}}$ when ${\mathbf{DIST}}=\text{'N'}$ and ${\mathbf{NPAR}}=2+2×{\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 must contain the autoregressive coefficients ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
The next IQ elements contain the coefficients ${\varphi }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
The next IP elements must contain the moving average coefficients ${\beta }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,p$.
If ${\mathbf{DIST}}=\text{'T'}$, the next element must contain an estimate for $\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}}=\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}$ and the next IQ elements contain the coefficients ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
The next IQ elements contain the coefficients ${\varphi }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
The next IP elements are the moving average coefficients ${\beta }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,p$.
If ${\mathbf{DIST}}=\text{'T'}$, the next element contains an estimate for $\mathit{df}$ then 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 IQ elements contain the standard errors for ${\varphi }_{\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$.
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 scores for ${\alpha }_{o}$, the next IQ elements contain the scores for ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$, the next IQ elements contain the scores for ${\varphi }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$, the next IP elements are the scores for ${\beta }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,p$.
If ${\mathbf{DIST}}=\text{'T'}$, the next element contains the scores 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 G13FGF is called.
Constraint: ${\mathbf{LDCOVR}}\ge {\mathbf{NPAR}}$.
16:   HP – REAL (KIND=nag_wp)Input/Output
On entry: if ${\mathbf{COPTS}}=\mathrm{.FALSE.}$ then HP is the value to be used for the pre-observed conditional variance, otherwise HP is not referenced.
On exit: if ${\mathbf{COPTS}}=\mathrm{.TRUE.}$ then 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 – LOGICALInput
On entry: if ${\mathbf{COPTS}}=\mathrm{.TRUE.}$, the routine provides initial parameter estimates of the regression terms, otherwise these are 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.
Constraint: ${\mathbf{MAXIT}}>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 G13FGF is called.
Constraint: ${\mathbf{LWORK}}\ge \left({\mathbf{NREG}}+3\right)×{\mathbf{NUM}}+3$.
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: G13FGF 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}}\le 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}}+3$.
${\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,2\right)$ model with Student's $t$-distributed residuals to some simulated data.
The process parameter estimates, $\stackrel{^}{\theta }$, are obtained using G13FGF, and a four step ahead volatility estimate is computed using G13FHF.
The data was simulated using G05PGF.

### 9.1  Program Text

Program Text (g13fgfe.f90)

### 9.2  Program Data

Program Data (g13fgfe.d)

### 9.3  Program Results

Program Results (g13fgfe.r)

G13FGF (PDF version)
G13 Chapter Contents
G13 Chapter Introduction
NAG Library Manual