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_stat_moments_ratio_quad_forms (g01nb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_stat_moments_ratio_quad_forms (g01nb) computes the moments of ratios of quadratic forms in Normal variables and related statistics.

Syntax

[lmax, rmom, abserr, ifail] = g01nb(a, b, sigma, l1, l2, eps, 'n', n, 'c', c, 'ela', ela, 'emu', emu)
[lmax, rmom, abserr, ifail] = nag_stat_moments_ratio_quad_forms(a, b, sigma, l1, l2, eps, 'n', n, 'c', c, 'ela', ela, 'emu', emu)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: mean and case were removed from the interface; c, ela and emu were made optional

Description

Let x have an n-dimensional multivariate Normal distribution with mean μ and variance-covariance matrix Σ. Then for a symmetric matrix A and symmetric positive semidefinite matrix B, nag_stat_moments_ratio_quad_forms (g01nb) computes a subset, l1 to l2, of the first 12 moments of the ratio of quadratic forms
R=xTAx/xTBx.  
The sth moment (about the origin) is defined as
ERs, (1)
where E denotes the expectation. Alternatively, this function will compute the following expectations:
ERsaTx (2)
and
ERsxTCx, (3)
where a is a vector of length n and C is a n by n symmetric matrix, if they exist. In the case of (2) the moments are zero if μ=0.
The conditions of theorems 1, 2 and 3 of Magnus (1986) and Magnus (1990) are used to check for the existence of the moments. If all the requested moments do not exist, the computations are carried out for those moments that are requested up to the maximum that exist, lMAX.
This function is based on the function QRMOM written by Magnus and Pesaran (1993a) and based on the theory given by Magnus (1986) and Magnus (1990). The computation of the moments requires first the computation of the eigenvectors of the matrix LTBL, where LLT=Σ. The matrix LTBL must be positive semidefinite and not null. Given the eigenvectors of this matrix, a function which has to be integrated over the range zero to infinity can be computed. This integration is performed using nag_quad_1d_inf (d01am).

References

Magnus J R (1986) The exact moments of a ratio of quadratic forms in Normal variables Ann. Économ. Statist. 4 95–109
Magnus J R (1990) On certain moments relating to quadratic forms in Normal variables: Further results Sankhyā, Ser. B 52 1–13
Magnus J R and Pesaran B (1993a) The evaluation of cumulants and moments of quadratic forms in Normal variables (CUM): Technical description Comput. Statist. 8 39–45
Magnus J R and Pesaran B (1993b) The evaluation of moments of quadratic forms and ratios of quadratic forms in Normal variables: Background, motivation and examples Comput. Statist. 8 47–55

Parameters

Compulsory Input Parameters

1:     aldan – double array
lda, the first dimension of the array, must satisfy the constraint ldan.
The n by n symmetric matrix A. Only the lower triangle is referenced.
2:     bldbn – double array
ldb, the first dimension of the array, must satisfy the constraint ldbn.
The n by n positive semidefinite symmetric matrix B. Only the lower triangle is referenced.
Constraint: the matrix B must be positive semidefinite.
3:     sigmaldsign – double array
ldsig, the first dimension of the array, must satisfy the constraint ldsign.
The n by n variance-covariance matrix Σ. Only the lower triangle is referenced.
Constraint: the matrix Σ must be positive definite.
4:     l1 int64int32nag_int scalar
The first moment to be computed, l1.
Constraint: 0<l1l2.
5:     l2 int64int32nag_int scalar
The last moment to be computed, l2.
Constraint: l1l212.
6:     eps – double scalar
The relative accuracy required for the moments, this value is also used in the checks for the existence of the moments.
If eps=0.0, a value of ε where ε is the machine precision used.
Constraint: eps=0.0 or epsmachine precision.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the first dimension of the arrays a, b, sigma and the second dimension of the arrays a, b, sigma. (An error is raised if these dimensions are not equal.)
n, the dimension of the quadratic form.
Constraint: n>1.
2:     cldc: – double array
The first dimension, ldc, of the array c must satisfy
  • if case='Q', ldcn;
  • otherwise ldc1.
The second dimension of the array c must be at least n if case='Q', and at least 1 otherwise.
If case='Q', c must contain the n by n symmetric matrix C; only the lower triangle is referenced.
If case'Q', c is not referenced.
3:     ela: – double array
The dimension of the array ela must be at least n if case='L', and at least 1 otherwise
If case='L', ela must contain the vector a of length n, otherwise ela is not referenced.
4:     emu: – double array
The dimension of the array emu must be at least n if mean='M', and at least 1 otherwise
If mean='M', emu must contain the n elements of the vector μ.
If mean='Z', emu is not referenced.

Output Parameters

1:     lmax int64int32nag_int scalar
The highest moment computed, lMAX. This will be l2 if ifail=0 on exit.
2:     rmoml2-l1+1 – double array
The l1 to lMAX moments.
3:     abserr – double scalar
The estimated maximum absolute error in any computed moment.
4:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Note: nag_stat_moments_ratio_quad_forms (g01nb) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

   ifail=1
On entry,n1,
orlda<n,
orldb<n,
orldsig<n,
orcase='Q' and ldc<n,
orcase'Q' and ldc<1,
orl1<1,
orl1>l2,
orl2>12,
orcase'R', 'L' or 'Q',
ormean'M' or 'Z',
oreps0.0 and eps<machine precision.
   ifail=2
On entry,Σ is not positive definite,
orb is not positive semidefinite or is null.
   ifail=3
None of the required moments can be computed.
   ifail=4
The matrix LTBL is not positive semidefinite or is null.
   ifail=5
The computation to compute the eigenvalues required in the calculation of moments has failed to converge: this is an unlikely error exit.
W  ifail=6
Only some of the required moments have been computed, the highest is given by lmax.
W  ifail=7
The required accuracy has not been achieved in the integration. An estimate of the accuracy is returned in abserr.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

The relative accuracy is specified by eps and an estimate of the maximum absolute error for all computed moments is returned in abserr.

Further Comments

None.

Example

This example is given by Magnus and Pesaran (1993b) and considers the simple autoregression:
yt=βyt-1+ut,  t=1,2,,n,  
where ut is a sequence of independent Normal variables with mean zero and variance one, and y0 is known. The least squares estimate of β, β^, is given by
β^=t=2nytyt-1 t=2nyt2 .  
Thus β^ can be written as a ratio of quadratic forms and its moments computed using nag_stat_moments_ratio_quad_forms (g01nb). The matrix A is given by
Ai+1,i=12, i=1,2,n-1; Ai,j=0, otherwise,  
and the matrix B is given by
Bi,i=1, i=1,2,n-1; Bi,j=0, otherwise.  
The value of Σ can be computed using the relationships
varyt=β2varyt-1+1  
and
covytyt+k=β covytyt+k- 1  
for k0 and vary1=1.
The values of β, y0, n, and the number of moments required are read in and the moments computed and printed.
function g01nb_example


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

% Problem parameters
n    = 10;
l1   = int64(1);
l2   = int64(3);
beta = 0.8;
y0   = 1.0;

% Setup a, b, emu, sigma for simple autoregression
a = zeros(n, n);
b = zeros(n, n);
a(2:n,  1:n-1) = 0.5*eye(n-1);
b(1:n-1,1:n-1) = eye(n-1);

emu = zeros(n,1);
for j=1:n
  emu(j) = y0*beta^j;
end
sigma = zeros(n,n);
sigma(1,1) = 1;
for j = 2:n
  sigma(j,j) = sigma(j-1,j-1)*beta^2 + 1;
end
for i = 1:n
  s = sigma(i,i);
  for j = i+1:n
    sigma(j,i) = s*beta^(j-i);
  end
end

% Compute moments
epsilon = 0;
[lmax, rmom, abserr, ifail] = ...
  g01nb( ...
         a, b, sigma, l1, l2, epsilon, 'emu', emu);

% Display results
fprintf(' n = %3d, beta = %6.3f, y0 = %6.3f\n\n', n, beta, y0);
fprintf('      Moments\n\n');
ival = double([l1:lmax]');
fprintf('%3d%12.4e\n',[ival rmom]');


g01nb example results

 n =  10, beta =  0.800, y0 =  1.000

      Moments

  1  6.8204e-01
  2  5.3569e-01
  3  4.4269e-01

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