NAG Library Routine Document
G01NAF
1 Purpose
G01NAF computes the cumulants and moments of quadratic forms in Normal variates.
2 Specification
SUBROUTINE G01NAF ( |
MOM, MEAN, N, A, LDA, EMU, SIGMA, LDSIG, L, RKUM, RMOM, WK, IFAIL) |
INTEGER |
N, LDA, LDSIG, L, IFAIL |
REAL (KIND=nag_wp) |
A(LDA,N), EMU(*), SIGMA(LDSIG,N), RKUM(L), RMOM(*), WK(3*N*(N+1)/2+N) |
CHARACTER(1) |
MOM, MEAN |
|
3 Description
Let
have an
-dimensional multivariate Normal distribution with mean
and variance-covariance matrix
. Then for a symmetric matrix
, G01NAF 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 routine is based on the routine CUM written by
Magnus and Pesaran (1993a) and based on the theory given by
Magnus (1978),
Magnus (1979) and
Magnus (1986).
4 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
5 Parameters
- 1: – CHARACTER(1)Input
-
On entry: indicates if moments are computed in addition to cumulants.
- Only cumulants are computed.
- Moments are computed in addition to cumulants.
Constraint:
or .
- 2: – CHARACTER(1)Input
-
On entry: indicates if the mean,
, is zero.
- is zero.
- The value of is supplied in EMU.
Constraint:
or .
- 3: – INTEGERInput
-
On entry: , the dimension of the quadratic form.
Constraint:
.
- 4: – REAL (KIND=nag_wp) arrayInput
-
On entry: the by symmetric matrix . Only the lower triangle is referenced.
- 5: – INTEGERInput
-
On entry: the first dimension of the array
A as declared in the (sub)program from which G01NAF is called.
Constraint:
.
- 6: – REAL (KIND=nag_wp) arrayInput
-
Note: the dimension of the array
EMU
must be at least
if
, and at least
otherwise.
On entry: if
,
EMU must contain the
elements of the vector
.
If
,
EMU is not referenced.
- 7: – REAL (KIND=nag_wp) arrayInput
-
On entry: the by variance-covariance matrix . Only the lower triangle is referenced.
Constraint:
the matrix must be positive definite.
- 8: – INTEGERInput
-
On entry: the first dimension of the array
SIGMA as declared in the (sub)program from which G01NAF is called.
Constraint:
.
- 9: – INTEGERInput
-
On entry: the required number of cumulants, and moments if specified.
Constraint:
.
- 10: – REAL (KIND=nag_wp) arrayOutput
-
On exit: the
L cumulants of the quadratic form.
- 11: – REAL (KIND=nag_wp) arrayOutput
-
Note: the dimension of the array
RMOM
must be at least
if
, and at least
otherwise.
On exit: if
, the
L moments of the quadratic form.
- 12: – REAL (KIND=nag_wp) arrayWorkspace
-
- 13: – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
-
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.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
In a range of tests the accuracy was found to be a modest multiple of
machine precision. See
Magnus and Pesaran (1993b).
8 Parallelism and Performance
G01NAF is not threaded by NAG in any implementation.
G01NAF makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
None.
10 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 G01NAF. 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.
10.1 Program Text
Program Text (g01nafe.f90)
10.2 Program Data
Program Data (g01nafe.d)
10.3 Program Results
Program Results (g01nafe.r)