PDF version (NAG web site
, 64-bit version, 64-bit version)
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:
At Mark 23: |
mean and case were removed from the interface; c, ela and emu were made optional |
Description
Let
have an
-dimensional multivariate Normal distribution with mean
and variance-covariance matrix
. Then for a symmetric matrix
and symmetric positive semidefinite matrix
,
nag_stat_moments_ratio_quad_forms (g01nb) computes a subset,
to
, of the first
moments of the ratio of quadratic forms
The
th moment (about the origin) is defined as
where
denotes the expectation. Alternatively, this function will compute the following expectations:
and
where
is a vector of length
and
is a
by
symmetric matrix, if they exist. In the case of
(2) the moments are zero if
.
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,
.
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
, where
. The matrix
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:
– double array
-
lda, the first dimension of the array, must satisfy the constraint
.
The by symmetric matrix . Only the lower triangle is referenced.
- 2:
– double array
-
ldb, the first dimension of the array, must satisfy the constraint
.
The by positive semidefinite symmetric matrix . Only the lower triangle is referenced.
Constraint:
the matrix must be positive semidefinite.
- 3:
– double array
-
ldsig, the first dimension of the array, must satisfy the constraint
.
The by variance-covariance matrix . Only the lower triangle is referenced.
Constraint:
the matrix must be positive definite.
- 4:
– int64int32nag_int scalar
-
The first moment to be computed, .
Constraint:
.
- 5:
– int64int32nag_int scalar
-
The last moment to be computed, .
Constraint:
.
- 6:
– double scalar
-
The relative accuracy required for the moments, this value is also used in the checks for the existence of the moments.
If
, a value of
where
is the
machine precision used.
Constraint:
or .
Optional Input Parameters
- 1:
– 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.)
, the dimension of the quadratic form.
Constraint:
.
- 2:
– double array
-
The first dimension,
, of the array
c must satisfy
- if , ;
- otherwise .
The second dimension of the array
c must be at least
if
, and at least
otherwise.
If
,
c must contain the
by
symmetric matrix
; only the lower triangle is referenced.
If
,
c is not referenced.
- 3:
– double array
-
The dimension of the array
ela
must be at least
if
, and at least
otherwise
If
,
ela must contain the vector
of length
, otherwise
ela is not referenced.
- 4:
– double array
-
The dimension of the array
emu
must be at least
if
, and at least
otherwise
If
,
emu must contain the
elements of the vector
.
If
,
emu is not referenced.
Output Parameters
- 1:
– int64int32nag_int scalar
-
The highest moment computed, . This will be if on exit.
- 2:
– double array
-
The to moments.
- 3:
– double scalar
-
The estimated maximum absolute error in any computed moment.
- 4:
– int64int32nag_int scalar
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.
-
-
On entry, | , |
or | , |
or | , |
or | , |
or | and , |
or | and , |
or | , |
or | , |
or | , |
or | , or , |
or | or , |
or | and . |
-
-
On entry, | is not positive definite, |
or | is not positive semidefinite or is null. |
-
-
None of the required moments can be computed.
-
-
The matrix is not positive semidefinite or is null.
-
-
The computation to compute the eigenvalues required in the calculation of moments has failed to converge: this is an unlikely error exit.
- W
-
Only some of the required moments have been computed, the highest is given by
lmax.
- W
-
The required accuracy has not been achieved in the integration. An estimate of the accuracy is returned in
abserr.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
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:
where
is a sequence of independent Normal variables with mean zero and variance one, and
is known. The least squares estimate of
,
, is given by
Thus
can be written as a ratio of quadratic forms and its moments computed using
nag_stat_moments_ratio_quad_forms (g01nb). The matrix
is given by
and the matrix
is given by
The value of
can be computed using the relationships
The values of , , , and the number of moments required are read in and the moments computed and printed.
Open in the MATLAB editor:
g01nb_example
function g01nb_example
fprintf('g01nb example results\n\n');
n = 10;
l1 = int64(1);
l2 = int64(3);
beta = 0.8;
y0 = 1.0;
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
epsilon = 0;
[lmax, rmom, abserr, ifail] = ...
g01nb( ...
a, b, sigma, l1, l2, epsilon, 'emu', emu);
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)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015