hide long namesshow long names
hide short namesshow short names
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_rand_times_garch_exp (g05pg)

Purpose

nag_rand_times_garch_exp (g05pg) generates a given number of terms of an exponential GARCH(p,q)GARCH(p,q) process (see Engle and Ng (1993)).

Syntax

[ht, et, r, state, ifail] = g05pg(dist, num, ip, iq, theta, df, fcall, r, state, 'lr', lr)
[ht, et, r, state, ifail] = nag_rand_times_garch_exp(dist, num, ip, iq, theta, df, fcall, r, state, 'lr', lr)

Description

An exponential GARCH(p,q)GARCH(p,q) process is represented by:
q q p
ln(ht) = α0 + αizti + φi(|zti|E[|zti|]) + βjln(htj),  t = 1,2,,T;
i = 1 i = 1 j = 1
ln(ht)=α0+i=1qαizt-i+i=1qϕi(|zt-i|-E[|zt-i|])+j=1pβjln(ht-j),  t=1,2,,T;
where zt = (εt)/(sqrt(ht)) zt= εtht , E[|zti|]E[|zt-i|] denotes the expected value of |zti||zt-i|, and εtψt1 = N(0,ht)εtψt-1=N(0,ht) or εtψt1 = St(df,ht)εtψt-1=St(df,ht). Here StSt is a standardized Student's tt-distribution with dfdf degrees of freedom and variance htht, TT is the number of observations in the sequence, εtεt is the observed value of the GARCH(p,q)GARCH(p,q) process at time tt, htht is the conditional variance at time tt, and ψtψt the set of all information up to time tt.
One of the initialization functions nag_rand_init_repeat (g05kf) (for a repeatable sequence if computed sequentially) or nag_rand_init_nonrepeat (g05kg) (for a non-repeatable sequence) must be called prior to the first call to nag_rand_times_garch_exp (g05pg).

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:     dist – string (length ≥ 1)
The type of distribution to use for εtεt.
dist = 'N'dist='N'
A Normal distribution is used.
dist = 'T'dist='T'
A Student's tt-distribution is used.
Constraint: dist = 'N'dist='N' or 'T''T'.
2:     num – int64int32nag_int scalar
TT, the number of terms in the sequence.
Constraint: num0num0.
3:     ip – int64int32nag_int scalar
The number of coefficients, βiβi, for i = 1,2,,pi=1,2,,p.
Constraint: ip0ip0.
4:     iq – int64int32nag_int scalar
The number of coefficients, αiαi, for i = 1,2,,qi=1,2,,q.
Constraint: iq1iq1.
5:     theta(2 × iq + ip + 12×iq+ip+1) – double array
The initial parameter estimates for the vector θθ. The first element must contain the coefficient αoαo and the next iq elements must contain the autoregressive coefficients αiαi, for i = 1,2,,qi=1,2,,q. The next iq elements must contain the coefficients φiϕi, for i = 1,2,,qi=1,2,,q. The next ip elements must contain the moving average coefficients βjβj, for j = 1,2,,pj=1,2,,p.
Constraints:
  • i = 1p βi1.0 i=1 p βi1.0;
  • (α0)/( 1 i = 1p βi ) log(x02am) α0 1- i=1 p βi - log(x02am) .
6:     df – int64int32nag_int scalar
The number of degrees of freedom for the Student's tt-distribution.
If dist = 'N'dist='N', df is not referenced.
Constraint: if dist = 'T'dist='T', df > 2df>2.
7:     fcall – logical scalar
If fcall = truefcall=true, a new sequence is to be generated, otherwise a given sequence is to be continued using the information in r.
8:     r(lr) – double array
lr, the dimension of the array, must satisfy the constraint lr2 × (ip + 2 × iq + 2)lr2×(ip+2×iq+2).
The array contains information required to continue a sequence if fcall = falsefcall=false.
9:     state( : :) – int64int32nag_int array
Note: the actual argument supplied must be the array state supplied to the initialization routines nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg).
Contains information on the selected base generator and its current state.

Optional Input Parameters

1:     lr – int64int32nag_int scalar
Default: The dimension of the array r.
The dimension of the array r as declared in the (sub)program from which nag_rand_times_garch_exp (g05pg) is called.
Constraint: lr2 × (ip + 2 × iq + 2)lr2×(ip+2×iq+2).

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     ht(num) – double array
The conditional variances htht, for t = 1,2,,Tt=1,2,,T, for the GARCH(p,q)GARCH(p,q) sequence.
2:     et(num) – double array
The observations εtεt, for t = 1,2,,Tt=1,2,,T, for the GARCH(p,q)GARCH(p,q) sequence.
3:     r(lr) – double array
Contains information that can be used in a subsequent call of nag_rand_times_garch_exp (g05pg), with fcall = falsefcall=false.
4:     state( : :) – int64int32nag_int array
Note: the actual argument supplied must be the array state supplied to the initialization routines nag_rand_init_repeat (g05kf) or nag_rand_init_nonrepeat (g05kg).
Contains updated information on the state of the generator.
5:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,dist'N'dist'N' or 'T''T'.
  ifail = 2ifail=2
On entry,num < 0num<0.
  ifail = 3ifail=3
On entry,ip < 0ip<0.
  ifail = 4ifail=4
On entry,iq < 1iq<1.
  ifail = 6ifail=6
On entry,dist = 'T'dist='T' and df2df2.
  ifail = 10ifail=10
The value of ip or iq is not the same as when r was set up in a previous call.
  ifail = 11ifail=11
On entry,lr < 2 × (ip + iq + 2)lr<2×(ip+iq+2).
  ifail = 12ifail=12
On entry,state vector was not initialized or has been corrupted.
  ifail = 20ifail=20
Invalid sequence generated, use different parameters.

Accuracy

Not applicable.

Further Comments

None.

Example

function nag_rand_times_garch_exp_example
% Initialize the seed
seed = [int64(1762543)];
% genid and subid identify the base generator
genid = int64(1);
subid =  int64(1);

dist = 'N';
num = 10;
ip = 1;
iq = 1;
theta = [0.1; -0.3; 0.1; 0.9];
df = int64(0);
fcall = true;
r = zeros(2*(2*ip+iq+2),1);
% Initialize the generator to a repeatable sequence
[state, ifail] = nag_rand_init_repeat(genid, subid, seed);

% Generate the first realisation
[ht, et, r, state, ifail] = nag_rand_times_garch_exp(dist, int64(num), int64(ip), int64(iq), ...
                                  theta, df, fcall, r, state);
% Display the results
if ifail == 0
  fprintf('\n Realisation Number 1\n');
  fprintf('   I            HT(I)            ET(I)\n');
  fprintf('  --------------------------------------\n');
  for i=1:num
    fprintf('  %2d  %16.4f %16.4f\n', i, ht(i), et(i));
  end
else
  fprintf('\n nag_rand_times_garch_exp exited with ifail = %d \n', ifail);
end

% Generate a second realisation
fcall = false;
[ht, et, r, state, ifail] = nag_rand_times_garch_exp(dist, int64(num), int64(ip), int64(iq), ...
                                  theta, df, fcall, r, state);
% Display the results
if ifail == 0
  fprintf('\n Realisation Number 2\n');
  fprintf('   I            HT(I)            ET(I)\n');
  fprintf('  --------------------------------------\n');
  for i=1:num
    fprintf('  %2d  %16.4f %16.4f\n', i, ht(i), et(i));
  end
else
  fprintf('\n nag_rand_times_garch_exp exited with ifail = %d \n', ifail);
end
 

 Realisation Number 1
   I            HT(I)            ET(I)
  --------------------------------------
   1            2.5098           0.5526
   2            2.1785          -1.8383
   3            3.3844           1.2180
   4            2.6780           1.3672
   5            2.0953          -1.8178
   6            3.2813          -0.0343
   7            2.9958          -0.5094
   8            3.0815           1.3978
   9            2.3961          -0.0070
  10            2.2445           0.6661

 Realisation Number 2
   I            HT(I)            ET(I)
  --------------------------------------
   1            1.9327          -2.2795
   2            3.5577          -1.2249
   3            4.1461           0.6424
   4            3.4455          -2.9920
   5            5.9199           0.5777
   6            4.8221          -1.2894
   7            5.3174          -1.6473
   8            6.1095           6.1689
   9            3.1579           2.2935
  10            2.2189           0.1141

function g05pg_example
% Initialize the seed
seed = [int64(1762543)];
% genid and subid identify the base generator
genid = int64(1);
subid =  int64(1);

dist = 'N';
num = 10;
ip = 1;
iq = 1;
theta = [0.1; -0.3; 0.1; 0.9];
df = int64(0);
fcall = true;
r = zeros(2*(2*ip+iq+2),1);
% Initialize the generator to a repeatable sequence
[state, ifail] = g05kf(genid, subid, seed);

% Generate the first realisation
[ht, et, r, state, ifail] = g05pg(dist, int64(num), int64(ip), int64(iq), ...
                                  theta, df, fcall, r, state);
% Display the results
if ifail == 0
  fprintf('\n Realisation Number 1\n');
  fprintf('   I            HT(I)            ET(I)\n');
  fprintf('  --------------------------------------\n');
  for i=1:num
    fprintf('  %2d  %16.4f %16.4f\n', i, ht(i), et(i));
  end
else
  fprintf('\n g05pg exited with ifail = %d \n', ifail);
end

% Generate a second realisation
fcall = false;
[ht, et, r, state, ifail] = g05pg(dist, int64(num), int64(ip), int64(iq), ...
                                  theta, df, fcall, r, state);
% Display the results
if ifail == 0
  fprintf('\n Realisation Number 2\n');
  fprintf('   I            HT(I)            ET(I)\n');
  fprintf('  --------------------------------------\n');
  for i=1:num
    fprintf('  %2d  %16.4f %16.4f\n', i, ht(i), et(i));
  end
else
  fprintf('\n g05pg exited with ifail = %d \n', ifail);
end
 

 Realisation Number 1
   I            HT(I)            ET(I)
  --------------------------------------
   1            2.5098           0.5526
   2            2.1785          -1.8383
   3            3.3844           1.2180
   4            2.6780           1.3672
   5            2.0953          -1.8178
   6            3.2813          -0.0343
   7            2.9958          -0.5094
   8            3.0815           1.3978
   9            2.3961          -0.0070
  10            2.2445           0.6661

 Realisation Number 2
   I            HT(I)            ET(I)
  --------------------------------------
   1            1.9327          -2.2795
   2            3.5577          -1.2249
   3            4.1461           0.6424
   4            3.4455          -2.9920
   5            5.9199           0.5777
   6            4.8221          -1.2894
   7            5.3174          -1.6473
   8            6.1095           6.1689
   9            3.1579           2.2935
  10            2.2189           0.1141


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–2013