Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_tsa_uni_garch_gjr_estim (g13fe)

## Purpose

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

## Syntax

[theta, se, sc, covr, hp, et, ht, lgf, ifail] = g13fe(dist, yt, x, ip, iq, nreg, mn, theta, hp, copts, maxit, tol, 'num', num, 'npar', npar)
[theta, se, sc, covr, hp, et, ht, lgf, ifail] = nag_tsa_uni_garch_gjr_estim(dist, yt, x, ip, iq, nreg, mn, theta, hp, copts, maxit, tol, 'num', num, 'npar', npar)
Note: the interface to this routine has changed since earlier releases of the toolbox:
 At Mark 25: nreg was made optional

## 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$.
nag_tsa_uni_garch_gjr_estim (g13fe) 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 nag_tsa_uni_garch_gjr_estim (g13fe)) 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'}$.

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

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{dist}$ – string (length ≥ 1)
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)$ – double array
The sequence of observations, ${y}_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$.
3:     $\mathrm{x}\left(\mathit{ldx},:\right)$ – double array
The first dimension of the array x must be at least ${\mathbf{num}}$.
The second dimension of the array x must be at least ${\mathbf{nreg}}$.
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{ip}$int64int32nag_int scalar
The number of coefficients, ${\beta }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,p$.
Constraint: ${\mathbf{ip}}\ge 0$ (see also npar).
5:     $\mathrm{iq}$int64int32nag_int scalar
The number of coefficients, ${\alpha }_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,q$.
Constraint: ${\mathbf{iq}}\ge 1$ (see also npar).
6:     $\mathrm{nreg}$int64int32nag_int scalar
$k$, the number of regression coefficients.
Constraint: ${\mathbf{nreg}}\ge 0$ (see also npar).
7:     $\mathrm{mn}$int64int32nag_int scalar
If ${\mathbf{mn}}=1$, the mean term ${b}_{0}$ will be included in the model.
Constraint: ${\mathbf{mn}}=0$ or $1$.
8:     $\mathrm{theta}\left({\mathbf{npar}}\right)$ – double array
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)=\mathit{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$.
9:     $\mathrm{hp}$ – double scalar
If ${\mathbf{copts}}\left(2\right)=\mathit{false}$, hp is the value to be used for the pre-observed conditional variance; otherwise hp is not referenced.
10:   $\mathrm{copts}\left(2\right)$ – logical array
The options to be used by nag_tsa_uni_garch_gjr_estim (g13fe).
${\mathbf{copts}}\left(1\right)=\mathit{true}$
Stationary conditions are enforced, otherwise they are not.
${\mathbf{copts}}\left(2\right)=\mathit{true}$
The function provides initial parameter estimates of the regression terms, otherwise these are to be provided by you.
11:   $\mathrm{maxit}$int64int32nag_int scalar
The maximum number of iterations to be used by the optimization function 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 when ${\mathbf{dist}}=\text{'N'}$; however the value of $\theta$ is not updated.
Constraint: ${\mathbf{maxit}}\ge 0$.
12:   $\mathrm{tol}$ – double scalar
The tolerance to be used by the optimization function when estimating the $\text{GARCH}\left(p,q\right)$ parameters.

### Optional Input Parameters

1:     $\mathrm{num}$int64int32nag_int scalar
Default: the dimension of the array yt and the first dimension of the array x. (An error is raised if these dimensions are not equal.)
$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}}$.
2:     $\mathrm{npar}$int64int32nag_int scalar
Default: the dimension of the array theta.
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$.

### Output Parameters

1:     $\mathrm{theta}\left({\mathbf{npar}}\right)$ – double array
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$.
2:     $\mathrm{se}\left({\mathbf{npar}}\right)$ – double array
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$.
3:     $\mathrm{sc}\left({\mathbf{npar}}\right)$ – double array
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$.
4:     $\mathrm{covr}\left(\mathit{ldcovr},{\mathbf{npar}}\right)$ – double array
The covariance matrix of the parameter estimates $\stackrel{^}{\theta }$, that is the inverse of the Fisher Information Matrix.
5:     $\mathrm{hp}$ – double scalar
If ${\mathbf{copts}}\left(2\right)=\mathit{true}$, hp is the estimated value of the pre-observed conditional variance.
6:     $\mathrm{et}\left({\mathbf{num}}\right)$ – double array
The estimated residuals, ${\epsilon }_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$.
7:     $\mathrm{ht}\left({\mathbf{num}}\right)$ – double array
The estimated conditional variances, ${h}_{\mathit{t}}$, for $\mathit{t}=1,2,\dots ,T$.
8:     $\mathrm{lgf}$ – double scalar
The value of the log-likelihood function at $\stackrel{^}{\theta }$.
9:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Note: nag_tsa_uni_garch_gjr_estim (g13fe) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:
${\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 $\mathit{ldcovr}<{\mathbf{npar}}$, or $\mathit{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, $\mathit{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.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

Not applicable.

None.

## 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 nag_tsa_uni_garch_gjr_estim (g13fe), and a four step ahead volatility estimate is computed using nag_tsa_uni_garch_gjr_forecast (g13ff).
The data was simulated using nag_rand_times_garch_gjr (g05pf).
```function g13fe_example

fprintf('g13fe example results\n\n');

mn  = int64(1);
nreg = int64(2);
yt = [7.23; 6.75; 7.21; 7.08; 6.60;
6.59; 7.00; 7.06; 6.82; 6.99;
7.05; 6.12; 7.47; 6.99; 7.26;
6.42; 7.12; 6.77; 7.32; 6.03;
6.78; 7.04; 6.27; 7.30; 7.71;
6.62; 8.13; 7.69; 7.62; 6.64;
8.16; 6.95; 7.15; 7.61; 7.42;
7.56; 8.25; 7.43; 7.84; 7.24;
7.63; 8.45; 8.17; 7.40; 7.62;
8.89; 8.14; 8.90; 7.79; 7.19;
7.55; 7.41; 7.93; 7.43; 8.87;
7.27; 8.09; 7.15; 8.21; 8.19;
7.84; 7.99; 8.90; 8.24; 7.97;
8.30; 8.23; 7.98; 7.73; 8.50;
7.71; 7.70; 8.61; 7.68; 8.66;
8.85; 8.09; 7.45; 6.15; 6.28;
7.59; 6.78; 9.32; 9.16; 8.77;
8.27; 7.24; 7.73; 9.01; 9.09;
7.55; 8.64; 7.97; 8.20; 7.72;
8.47; 8.06; 5.55; 8.75; 10.15];
x = [2.40, 0.12;  2.40, 0.12; 2.40, 0.13; 2.40, 0.14;
2.40, 0.14;  2.40, 0.15; 2.40, 0.16; 2.40, 0.16;
2.40, 0.17;  2.41, 0.18; 2.41, 0.19; 2.41, 0.19;
2.41, 0.20;  2.41, 0.21; 2.41, 0.21; 2.41, 0.22;
2.41, 0.23;  2.41, 0.23; 2.41, 0.24; 2.42, 0.25;
2.42, 0.25;  2.42, 0.26; 2.42, 0.26; 2.42, 0.27;
2.42, 0.28;  2.42, 0.28; 2.42, 0.29; 2.42, 0.30;
2.42, 0.30;  2.43, 0.31; 2.43, 0.32; 2.43, 0.32;
2.43, 0.33;  2.43, 0.33; 2.43, 0.34; 2.43, 0.35;
2.43, 0.35;  2.43, 0.36; 2.43, 0.37; 2.44, 0.37;
2.44, 0.38;  2.44, 0.38; 2.44, 0.39; 2.44, 0.39;
2.44, 0.40;  2.44, 0.41; 2.44, 0.41; 2.44, 0.42;
2.44, 0.42;  2.45, 0.43; 2.45, 0.43; 2.45, 0.44;
2.45, 0.45;  2.45, 0.45; 2.45, 0.46; 2.45, 0.46;
2.45, 0.47;  2.45, 0.47; 2.45, 0.48; 2.46, 0.48;
2.46, 0.49;  2.46, 0.49; 2.46, 0.50; 2.46, 0.50;
2.46, 0.51;  2.46, 0.51; 2.46, 0.52; 2.46, 0.52;
2.46, 0.53;  2.47, 0.53; 2.47, 0.54; 2.47, 0.54;
2.47, 0.54;  2.47, 0.55; 2.47, 0.55; 2.47, 0.56;
2.47, 0.56;  2.47, 0.57; 2.47, 0.57; 2.48, 0.57;
2.48, 0.58;  2.48, 0.58; 2.48, 0.59; 2.48, 0.59;
2.48, 0.59;  2.48, 0.60; 2.48, 0.60; 2.48, 0.61;
2.48, 0.61;  2.49, 0.61; 2.49, 0.62; 2.49, 0.62;
2.49, 0.62;  2.49, 0.63; 2.49, 0.63; 2.49, 0.63;
2.49, 0.64;  2.49, 0.64; 2.49, 0.64; 2.50, 0.64];
dist = 't';
ip = int64(1);
iq = int64(1);
copts = [true; true];
maxit = int64(200);
tol = 0.00001;
hp = 0;
% Theta is [alpha_0; alpha_1; beta_1; gamma; df; b_0]
theta = [0.025; 0.05; 0.4; 0.045; 3.25; 1.5; 0; 0];
nt = int64(4);
% Fit the GARCH model
[theta, se, sc, covr, hp, et, ht, lgf, ifail] = ...
g13fe( ...
dist, yt, x, ip, iq, mn, theta, hp, copts, maxit, tol);

% Extract the estimate of the asymmetry parameter from theta
gamma = theta(4);

% Calculate the volatility forecast
[fht, ifail] = g13ff( ...
nt, ip, iq, theta, gamma, ht, et);

% Output the results
fprintf('\n               Parameter        Standard\n');
fprintf('               estimates         errors\n');

% Output the coefficient alpha_0
fprintf('Alpha0 %16.2f%16.2f\n', theta(1), se(1));
l = 2;

% Output the coefficients alpha_i
for i = l:l+iq-1
fprintf('Alpha%d %16.2f%16.2f\n', i-1, theta(i), se(i));
end
l = l+iq;

% Output the coefficients beta_j
fprintf('\n');
for i = l:l+ip-1
fprintf(' Beta%d %16.2f%16.2f\n', i-l+1, theta(i), se(i));
end
l = l+ip;

% Output the estimated asymmetry parameter, gamma
fprintf('\n Gamma %16.2f%16.2f\n', theta(l), se(l));
l = l+1;

% Output the estimated degrees of freedom, df
if (dist == 't')
fprintf('\n    DF %16.2f%16.2f\n', theta(l), se(l));
l = l + 1;
end

% Output the estimated mean term, b_0
if (mn == 1)
fprintf('\n    B0 %16.2f%16.2f\n', theta(l), se(l));
l = l + 1;
end

% Output the estimated linear regression coefficients, b_i
for i = l:l+nreg-1
fprintf('    B%d %16.2f%16.2f\n', i-l+1, theta(i), se(i));
end

% Display the volatility forecast
fprintf('\nVolatility forecast = %12.2f\n', fht(nt));

```
```g13fe example results

Parameter        Standard
estimates         errors
Alpha0             0.08            0.12
Alpha1             0.00            0.85

Beta1             0.67            0.19

Gamma             0.35            0.63

DF             5.03            5.13

B0            50.22            3.33
B1           -18.48            1.43
B2             6.45            0.54

Volatility forecast =         0.61
```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015