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)

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:
Mark 23: mean and case dropped from interface, c, ela, emu now optional
.

Description

Let xx have an nn-dimensional multivariate Normal distribution with mean μμ and variance-covariance matrix ΣΣ. Then for a symmetric matrix AA and symmetric positive semidefinite matrix BB, nag_stat_moments_ratio_quad_forms (g01nb) computes a subset, l1l1 to l2l2, of the first 1212 moments of the ratio of quadratic forms
R = xTAx / xTBx.
R=xTAx/xTBx.
The ssth moment (about the origin) is defined as
E(Rs),
E(Rs),
(1)
where EE denotes the expectation. Alternatively, this function will compute the following expectations:
E(Rs(aTx))
E(Rs(aTx))
(2)
and
E(Rs(xTCx)),
E(Rs(xTCx)),
(3)
where aa is a vector of length nn and CC is a nn by nn symmetric matrix, if they exist. In the case of (2) the moments are zero if μ = 0μ=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, lMAXlMAX.
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 LTBLLTBL, where LLT = ΣLLT=Σ. The matrix LTBLLTBL 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:     a(lda,n) – double array
lda, the first dimension of the array, must satisfy the constraint ldanldan.
The nn by nn symmetric matrix AA. Only the lower triangle is referenced.
2:     b(ldb,n) – double array
ldb, the first dimension of the array, must satisfy the constraint ldbnldbn.
The nn by nn positive semidefinite symmetric matrix BB. Only the lower triangle is referenced.
Constraint: the matrix BB must be positive semidefinite.
3:     sigma(ldsig,n) – double array
ldsig, the first dimension of the array, must satisfy the constraint ldsignldsign.
The nn by nn 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, l1l1.
Constraint: 0 < l1l20<l1l2.
5:     l2 – int64int32nag_int scalar
The last moment to be computed, l2l2.
Constraint: l1l212l1l212.
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.0eps=0.0, a value of sqrt(ε)ε where εε is the machine precision used.
Constraint: eps = 0.0eps=0.0 or epsmachine precisionepsmachine 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.)
nn, the dimension of the quadratic form.
Constraint: n > 1n>1.
2:     c(ldc, : :) – double array
The first dimension, ldc, of the array c must satisfy
  • if case = 'Q'case='Q', ldcnldcn;
  • otherwise ldc1ldc1.
The second dimension of the array must be at least nn if case = 'Q'case='Q', and at least 11 otherwise
If case = 'Q'case='Q', c must contain the nn by nn symmetric matrix CC; only the lower triangle is referenced.
If case'Q'case'Q', c is not referenced.
3:     ela( : :) – double array
Note: the dimension of the array ela must be at least nn if case = 'L'case='L', and at least 11 otherwise.
If case = 'L'case='L', ela must contain the vector aa of length nn, otherwise a is not referenced.
4:     emu( : :) – double array
Note: the dimension of the array emu must be at least nn if mean = 'M'mean='M', and at least 11 otherwise.
If mean = 'M'mean='M', emu must contain the nn elements of the vector μμ.
If mean = 'Z'mean='Z', emu is not referenced.

Input Parameters Omitted from the MATLAB Interface

case mean lda ldb ldc ldsig wk

Output Parameters

1:     lmax – int64int32nag_int scalar
The highest moment computed, lMAXlMAX. This will be l2l2 if ifail = 0ifail=0 on exit.
2:     rmom(l2l1 + 1l2-l1+1) – double array
The l1l1 to lMAXlMAX moments.
3:     abserr – double scalar
The estimated maximum absolute error in any computed moment.
4:     ifail – int64int32nag_int scalar
ifail = 0ifail=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 = 1ifail=1
On entry,n1n1,
orlda < nlda<n,
orldb < nldb<n,
orldsig < nldsig<n,
orcase = 'Q'case='Q' and ldc < nldc<n,
orcase'Q'case'Q' and ldc < 1ldc<1,
orl1 < 1l1<1,
orl1 > l2l1>l2,
orl2 > 12l2>12,
orcase'R'case'R', 'L''L' or 'Q''Q',
ormean'M'mean'M' or 'Z''Z',
oreps0.0eps0.0 and eps < machine precisioneps<machine precision.
  ifail = 2ifail=2
On entry,ΣΣ is not positive definite,
orbb is not positive semidefinite or is null.
  ifail = 3ifail=3
None of the required moments can be computed.
  ifail = 4ifail=4
The matrix LTBLLTBL is not positive semidefinite or is null.
  ifail = 5ifail=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 = 6ifail=6
Only some of the required moments have been computed, the highest is given by lmax.
W ifail = 7ifail=7
The required accuracy has not been achieved in the integration. An estimate of the accuracy is returned in abserr.

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

function nag_stat_moments_ratio_quad_forms_example
fcase = 'Ratio';
a = zeros(10, 10);
b = zeros(10, 10);
for i=1:9
  a(i+1, i) = 0.5;
  b(i, i)   = 1;
end
emu = [0.8;
     0.64;
     0.512;
     0.4096;
     0.32768;
     0.262144;
     0.2097152;
     0.16777216;
     0.134217728;
     0.1073741824000001];
beta = 0.8;
sigma = zeros(10, 10);
sigma(1,1) = 1;
for i=2:10
  sigma(i,i) = beta*beta*sigma(i-1,i-1)+1;
end
for i=1:10
  for j=i+1:10
    sigma(j,i) = beta*sigma(j-1,i);
  end
end
l1 = int64(1);
l2 = int64(3);
epsilon = 0;
[lmax, rmom, abserr, ifail] = ...
    nag_stat_moments_ratio_quad_forms(a, b, sigma, l1, l2, epsilon, 'emu', emu)
 

lmax =

                    3


rmom =

    0.6820
    0.5357
    0.4427


abserr =

   8.4646e-10


ifail =

                    0


function g01nb_example
fcase = 'Ratio';
a = zeros(10, 10);
b = zeros(10, 10);
for i=1:9
  a(i+1, i) = 0.5;
  b(i, i)   = 1;
end
emu = [0.8;
     0.64;
     0.512;
     0.4096;
     0.32768;
     0.262144;
     0.2097152;
     0.16777216;
     0.134217728;
     0.1073741824000001];
beta = 0.8;
sigma = zeros(10, 10);
sigma(1,1) = 1;
for i=2:10
  sigma(i,i) = beta*beta*sigma(i-1,i-1)+1;
end
for i=1:10
  for j=i+1:10
    sigma(j,i) = beta*sigma(j-1,i);
  end
end
l1 = int64(1);
l2 = int64(3);
epsilon = 0;
[lmax, rmom, abserr, ifail] = g01nb(a, b, sigma, l1, l2, epsilon, 'emu', emu)
 

lmax =

                    3


rmom =

    0.6820
    0.5357
    0.4427


abserr =

   8.4646e-10


ifail =

                    0



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