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

# NAG Library Routine DocumentG13FAF

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

G13FAF estimates the parameters of either a standard univariate regression GARCH process, or a univariate regression-type I $\text{AGARCH}\left(p,q\right)$ process (see Engle and Ng (1993)).

## 2  Specification

 SUBROUTINE G13FAF ( DIST, YT, X, LDX, NUM, IP, IQ, NREG, MN, ISYM, NPAR, THETA, SE, SC, COVR, LDCOVR, HP, ET, HT, LGF, COPTS, MAXIT, TOL, WORK, LWORK, IFAIL)
 INTEGER LDX, NUM, IP, IQ, NREG, MN, ISYM, 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-type I $\text{AGARCH}\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=1qαi εt-i+γ 2+∑i=1pβiht-i, t=1,2,…,T$ (2)
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 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$.
G13FAF 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'}$.
ISYM, MN and 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{ISYM}}=0$,
• ${\mathbf{MN}}=0$,
• ${\mathbf{NREG}}=0$ and
• $\theta$ is a $\left(p+q+1\right)$ vector when ${\mathbf{DIST}}=\text{'N'}$ and a $\left(p+q+2\right)$ vector when ${\mathbf{DIST}}=\text{'T'}$.
No Regression
• ${y}_{t}={b}_{o}+{\epsilon }_{t}$,
• ${\mathbf{ISYM}}=0$,
• ${\mathbf{MN}}=1$,
• ${\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'}$.
Note:  if the ${y}_{t}=\mu +{\epsilon }_{t}$, where $\mu$ is known (not to be estimated by G13FAF) 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{ISYM}}=0$,
• ${\mathbf{MN}}=0$,
• ${\mathbf{NREG}}=k$ and
• $\theta$ is a $\left(p+q+k+1\right)$ vector when ${\mathbf{DIST}}=\text{'N'}$ and a $\left(p+q+k+2\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
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 ${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:     $\mathrm{YT}\left({\mathbf{NUM}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: the sequence of observations, ${y}_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$.
3:     $\mathrm{X}\left({\mathbf{LDX}},*\right)$ – 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:     $\mathrm{LDX}$ – INTEGERInput
On entry: the first dimension of the array X as declared in the (sub)program from which G13FAF is called.
Constraint: ${\mathbf{LDX}}\ge {\mathbf{NUM}}$.
5:     $\mathrm{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:     $\mathrm{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:     $\mathrm{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:     $\mathrm{NREG}$ – INTEGERInput
On entry: $k$, the number of regression coefficients.
Constraint: ${\mathbf{NREG}}\ge 0$ (see also NPAR).
9:     $\mathrm{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:   $\mathrm{ISYM}$ – INTEGERInput
On entry: if ${\mathbf{ISYM}}=1$, the asymmetry term $\gamma$ will be included in the model.
Constraint: ${\mathbf{ISYM}}=0$ or $1$.
11:   $\mathrm{NPAR}$ – INTEGERInput
On entry: the number of parameters to be included in the model. ${\mathbf{NPAR}}=1+{\mathbf{IQ}}+{\mathbf{IP}}+{\mathbf{ISYM}}+{\mathbf{MN}}+{\mathbf{NREG}}$ when ${\mathbf{DIST}}=\text{'N'}$, and ${\mathbf{NPAR}}=2+{\mathbf{IQ}}+{\mathbf{IP}}+{\mathbf{ISYM}}+{\mathbf{MN}}+{\mathbf{NREG}}$ when ${\mathbf{DIST}}=\text{'T'}$.
Constraint: ${\mathbf{NPAR}}<20$.
12:   $\mathrm{THETA}\left({\mathbf{NPAR}}\right)$ – 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 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$.
If ${\mathbf{ISYM}}=1$, the next element must contain the asymmetry parameter $\gamma$.
If ${\mathbf{DIST}}=\text{'T'}$, the next element must contain $\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 coefficients ${\beta }_{\mathit{j}}$, for $\mathit{j}=1,2,\dots ,p$.
If ${\mathbf{ISYM}}=1$, 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$.
13:   $\mathrm{SE}\left({\mathbf{NPAR}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: the standard errors for $\stackrel{^}{\theta }$.
The first element contains the standard error for ${\alpha }_{o}$. 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$.
If ${\mathbf{ISYM}}=1$, 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$.
14:   $\mathrm{SC}\left({\mathbf{NPAR}}\right)$ – 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 score for ${\alpha }_{\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{ISYM}}=1$, 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$.
15:   $\mathrm{COVR}\left({\mathbf{LDCOVR}},{\mathbf{NPAR}}\right)$ – 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.
16:   $\mathrm{LDCOVR}$ – INTEGERInput
On entry: the first dimension of the array COVR as declared in the (sub)program from which G13FAF is called.
Constraint: ${\mathbf{LDCOVR}}\ge {\mathbf{NPAR}}$.
17:   $\mathrm{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.
18:   $\mathrm{ET}\left({\mathbf{NUM}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: the estimated residuals, ${\epsilon }_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$.
19:   $\mathrm{HT}\left({\mathbf{NUM}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: the estimated conditional variances, ${h}_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$.
20:   $\mathrm{LGF}$ – REAL (KIND=nag_wp)Output
On exit: the value of the log-likelihood function at $\stackrel{^}{\theta }$.
21:   $\mathrm{COPTS}\left(2\right)$ – LOGICAL arrayInput
On entry: the options to be used by G13FAF.
${\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.
22:   $\mathrm{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$.
23:   $\mathrm{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.
24:   $\mathrm{WORK}\left({\mathbf{LWORK}}\right)$ – REAL (KIND=nag_wp) arrayWorkspace
25:   $\mathrm{LWORK}$ – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which G13FAF is called.
Constraint: ${\mathbf{LWORK}}\ge \left({\mathbf{NREG}}+3\right)×{\mathbf{NUM}}+{\mathbf{NPAR}}+403$.
26:   $\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, 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: G13FAF 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{ISYM}}>1$, or ${\mathbf{ISYM}}<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.
${\mathbf{IFAIL}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
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

G13FAF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
G13FAF makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
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 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 G13FAF, and a four step ahead volatility estimate is computed using G13FBF.
The data was simulated using G05PDF.

### 10.1  Program Text

Program Text (g13fafe.f90)

### 10.2  Program Data

Program Data (g13fafe.d)

### 10.3  Program Results

Program Results (g13fafe.r)

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