PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_stat_moments_quad_form (g01na)
Purpose
nag_stat_moments_quad_form (g01na) computes the cumulants and moments of quadratic forms in Normal variates.
Syntax
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: |
mom and mean were removed from the interface; emu was made optional |
Description
Let
have an
-dimensional multivariate Normal distribution with mean
and variance-covariance matrix
. Then for a symmetric matrix
,
nag_stat_moments_quad_form (g01na) computes up to the first
moments and cumulants of the quadratic form
. The
th moment (about the origin) is defined as
where
denotes expectation. The
th moment of
can also be found as the coefficient of
in the expansion of
. The
th cumulant is defined as the coefficient of
in the expansion of
.
The function is based on the function CUM written by
Magnus and Pesaran (1993a) and based on the theory given by
Magnus (1978),
Magnus (1979) and
Magnus (1986).
References
Magnus J R (1978) The moments of products of quadratic forms in Normal variables Statist. Neerlandica 32 201–210
Magnus J R (1979) The expectation of products of quadratic forms in Normal variables: the practice Statist. Neerlandica 33 131–136
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 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
-
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.
- 3:
– int64int32nag_int scalar
-
The required number of cumulants, and moments if specified.
Constraint:
.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the arrays
a,
sigma and the second dimension of the arrays
a,
sigma. (An error is raised if these dimensions are not equal.)
, the dimension of the quadratic form.
Constraint:
.
- 2:
– double array
-
The dimension of the array
emu
must be at least
if
, and at least
otherwise
If supplied,
emu must contain the
elements of the vector
.
Output Parameters
- 1:
– double array
-
The
l cumulants of the quadratic form.
- 2:
– double array
-
The dimension of the array
rmom will be
if
and
otherwise
If
, the
l moments of the quadratic form.
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | , |
or | , |
or | , |
or | , |
or | or , |
or | or . |
-
-
On entry, | the matrix is not positive definite. |
-
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
In a range of tests the accuracy was found to be a modest multiple of
machine precision. See
Magnus and Pesaran (1993b).
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 moments of the quadratic form
are computed using
nag_stat_moments_quad_form (g01na). The matrix
is given by:
The value of
can be computed using the relationships
and
for
and
.
The values of , , , and the number of moments required are read in and the moments and cumulants printed.
Open in the MATLAB editor:
g01na_example
function g01na_example
fprintf('g01na example results\n\n');
n = 10;
l = int64(4);
beta = 0.8;
con = 1.0;
a = zeros(n,n);
a(2:n,1:n-1) = 0.5*eye(n-1);
emu = zeros(n,1);
for j=1:n
emu(j) = con*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
[rkum, rmom, ifail] = g01na( ...
a, sigma, l, 'emu', emu);
fprintf(' n = %3d, beta = %6.3f, con = %6.3f\n\n', n, beta, con);
fprintf(' Cumulants Moments\n\n');
ival = double([1:l]');
fprintf('%3d%12.4e %12.4e\n',[ival rkum rmom]');
g01na example results
n = 10, beta = 0.800, con = 1.000
Cumulants Moments
1 1.7517e+01 1.7517e+01
2 3.5010e+02 6.5695e+02
3 1.6091e+04 3.9865e+04
4 1.1700e+06 3.4039e+06
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015