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

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_tsa_uni_garch_asym2_forecast (g13fd)

## Purpose

nag_tsa_uni_garch_asym2_forecast (g13fd) forecasts the conditional variances, ht,t = T + 1,,T + ξ${h}_{t},t=T+1,\dots ,T+\xi$ from a type II AGARCH(p,q)$\text{AGARCH}\left(p,q\right)$ sequence, where ξ$\xi$ is the forecast horizon and T$T$ is the current time (see Engle and Ng (1993)).

## Syntax

[fht, ifail] = g13fd(nt, ip, iq, theta, gamma, ht, et, 'num', num)
[fht, ifail] = nag_tsa_uni_garch_asym2_forecast(nt, ip, iq, theta, gamma, ht, et, 'num', num)

## Description

Assume the GARCH(p,q)$\text{GARCH}\left(p,q\right)$ process can be represented by:
 q p ht = α0 + ∑ αi(|εt − i| + γεt − i)2 + ∑ βiht − i,  t = 1,2, … ,T. i = 1 i = 1
$ht=α0+∑i=1qαi (|εt-i|+γεt-i) 2+∑i=1pβiht-i, t=1,2,…,T.$
where εtψt1 = N(0,ht)${\epsilon }_{t}\mid {\psi }_{t-1}=N\left(0,{h}_{t}\right)$ or εtψt1 = St(df,ht)${\epsilon }_{t}\mid {\psi }_{t-1}={S}_{t}\left(\mathit{df},{h}_{t}\right)$, has been modelled by nag_tsa_uni_garch_asym2_estim (g13fc) and the estimated conditional variances and residuals are contained in the arrays ht and et respectively.
nag_tsa_uni_garch_asym2_forecast (g13fd) will then use the last max (p,q)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(p,q\right)$ elements of the arrays ht and et to estimate the conditional variance forecasts, htψT${h}_{t}\mid {\psi }_{T}$, where t = T + 1,,T + ξ$t=T+1,\dots ,T+\xi$ and ξ$\xi$ is the forecast horizon.

## 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
Hamilton J (1994) Time Series Analysis Princeton University Press

## Parameters

### Compulsory Input Parameters

1:     nt – int64int32nag_int scalar
ξ$\xi$, the forecast horizon.
Constraint: nt > 0${\mathbf{nt}}>0$.
2:     ip – int64int32nag_int scalar
The number of coefficients, βi${\beta }_{\mathit{i}}$, for i = 1,2,,p$\mathit{i}=1,2,\dots ,p$.
Constraints:
• max (ip,iq)20$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ip}},{\mathbf{iq}}\right)\le 20$;
• ip0${\mathbf{ip}}\ge 0$.
3:     iq – int64int32nag_int scalar
The number of coefficients, αi${\alpha }_{\mathit{i}}$, for i = 1,2,,q$\mathit{i}=1,2,\dots ,q$.
Constraints:
• max (ip,iq)20$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ip}},{\mathbf{iq}}\right)\le 20$;
• iq1${\mathbf{iq}}\ge 1$.
4:     theta(iq + ip + 1${\mathbf{iq}}+{\mathbf{ip}}+1$) – double array
The first element must contain the coefficient αo${\alpha }_{o}$ and the next iq elements must contain the coefficients αi${\alpha }_{\mathit{i}}$, for i = 1,2,,q$\mathit{i}=1,2,\dots ,q$. The remaining ip elements must contain the coefficients βj${\beta }_{\mathit{j}}$, for j = 1,2,,p$\mathit{j}=1,2,\dots ,p$.
5:     gamma – double scalar
The asymmetry parameter γ$\gamma$ for the GARCH(p,q)$\text{GARCH}\left(p,q\right)$ sequence.
6:     ht(num) – double array
num, the dimension of the array, must satisfy the constraint max (ip,iq)num$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ip}},{\mathbf{iq}}\right)\le {\mathbf{num}}$.
The sequence of past conditional variances for the GARCH(p,q)$\text{GARCH}\left(p,q\right)$ process, ht${h}_{\mathit{t}}$, for t = 1,2,,T$\mathit{t}=1,2,\dots ,T$.
7:     et(num) – double array
num, the dimension of the array, must satisfy the constraint max (ip,iq)num$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ip}},{\mathbf{iq}}\right)\le {\mathbf{num}}$.
The sequence of past residuals for the GARCH(p,q)$\text{GARCH}\left(p,q\right)$ process, εt${\epsilon }_{\mathit{t}}$, for t = 1,2,,T$\mathit{t}=1,2,\dots ,T$.

### Optional Input Parameters

1:     num – int64int32nag_int scalar
Default: The dimension of the arrays ht, et. (An error is raised if these dimensions are not equal.)
The number of terms in the arrays ht and et from the modelled sequence.
Constraint: max (ip,iq)num$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ip}},{\mathbf{iq}}\right)\le {\mathbf{num}}$.

None.

### Output Parameters

1:     fht(nt) – double array
The forecast values of the conditional variance, ht${h}_{t}$, for t = T + 1,,T + ξ$\mathit{t}=T+1,\dots ,T+\xi$.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, num < max (ip,iq)${\mathbf{num}}<\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ip}},{\mathbf{iq}}\right)$, or iq < 1${\mathbf{iq}}<1$, or ip < 0${\mathbf{ip}}<0$, or max (ip,iq) > 20$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{ip}},{\mathbf{iq}}\right)>20$, or nt ≤ 0${\mathbf{nt}}\le 0$.

Not applicable.

None.

## Example

```function nag_tsa_uni_garch_asym2_forecast_example
mn  = int64(1);
nreg = int64(2);
yt = [ 8.87;  9.82;  9.02;  9.24;  9.46;
8.93; 10.20;  9.19;  8.27;  9.08;
9.11;  9.95;  8.11;  9.13;  9.49;
10.08;  9.74; 10.72;  8.94; 10.10;
10.19;  9.68;  9.09;  9.88;  9.55;
9.52;  8.45;  9.14;  9.52;  9.27;
9.50;  9.93;  9.86;  9.16;  9.00;
9.28;  9.83;  9.86;  9.55; 10.12;
8.47; 10.10;  8.70;  9.44;  9.10;
7.54;  8.08;  9.47; 12.32; 10.75;
11.66; 10.59; 10.93; 10.21;  9.39;
9.74; 10.91;  9.46; 10.32; 11.00;
9.47;  8.14;  9.88; 11.15; 11.21;
10.06;  9.50;  9.56;  9.23; 10.88;
10.93;  9.89;  9.89;  9.37; 10.44;
9.52;  9.92;  7.44; 10.36;  7.73;
10.53;  9.38; 11.14; 10.73; 10.02;
10.36; 10.18;  9.52;  9.59; 12.73;
9.38;  8.69;  9.78; 11.85;  9.23;
10.13; 10.77;  8.68; 10.39;  9.74];
x = [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.40;  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.41;  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.42;  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.43;  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.44;  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.45;  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.46;  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.47;  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.48;  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.49;  0.64, 2.50];
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.05; 0.05; 0.4; -0.2; 2.6; 1.5; 0; 0];
nt = int64(4);
% Fit the GARCH model
[theta, se, sc, covar, hp, et, ht, lgf, ifail] = ...
nag_tsa_uni_garch_asym2_estim(dist, yt, x, ip, iq, nreg, mn, theta, hp, copts, maxit, tol);

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

% Calculate the volatility forecast
[fht, ifail] = nag_tsa_uni_garch_asym2_forecast(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));
```
```

Parameter        Standard
estimates         errors
Alpha0             6.82            1.68
Alpha1             0.00            1.00

Beta1             0.00            3.17

Gamma            -0.36            1.01

DF             2.10            0.33

B0           -25.14            4.80
B1            -0.95            0.90
B2            14.41            2.08

Volatility forecast =         6.82

```
```function g13fd_example
mn  = int64(1);
nreg = int64(2);
yt = [ 8.87;  9.82;  9.02;  9.24;  9.46;
8.93; 10.20;  9.19;  8.27;  9.08;
9.11;  9.95;  8.11;  9.13;  9.49;
10.08;  9.74; 10.72;  8.94; 10.10;
10.19;  9.68;  9.09;  9.88;  9.55;
9.52;  8.45;  9.14;  9.52;  9.27;
9.50;  9.93;  9.86;  9.16;  9.00;
9.28;  9.83;  9.86;  9.55; 10.12;
8.47; 10.10;  8.70;  9.44;  9.10;
7.54;  8.08;  9.47; 12.32; 10.75;
11.66; 10.59; 10.93; 10.21;  9.39;
9.74; 10.91;  9.46; 10.32; 11.00;
9.47;  8.14;  9.88; 11.15; 11.21;
10.06;  9.50;  9.56;  9.23; 10.88;
10.93;  9.89;  9.89;  9.37; 10.44;
9.52;  9.92;  7.44; 10.36;  7.73;
10.53;  9.38; 11.14; 10.73; 10.02;
10.36; 10.18;  9.52;  9.59; 12.73;
9.38;  8.69;  9.78; 11.85;  9.23;
10.13; 10.77;  8.68; 10.39;  9.74];
x = [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.40;  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.41;  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.42;  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.43;  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.44;  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.45;  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.46;  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.47;  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.48;  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.49;  0.64, 2.50];
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.05; 0.05; 0.4; -0.2; 2.6; 1.5; 0; 0];
nt = int64(4);
% Fit the GARCH model
[theta, se, sc, covar, hp, et, ht, lgf, ifail] = ...
g13fc(dist, yt, x, ip, iq, nreg, mn, theta, hp, copts, maxit, tol);

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

% Calculate the volatility forecast
[fht, ifail] = g13fd(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));
```
```

Parameter        Standard
estimates         errors
Alpha0             6.82            1.68
Alpha1             0.00            1.00

Beta1             0.00            3.17

Gamma            -0.36            1.01

DF             2.10            0.33

B0           -25.14            4.80
B1            -0.95            0.90
B2            14.41            2.08

Volatility forecast =         6.82

```