NAG CL Interface
g01nbc (moments_ratio_quad_forms)
1
Purpose
g01nbc computes the moments of ratios of quadratic forms in Normal variables and related statistics.
2
Specification
The function may be called by the names: g01nbc, nag_stat_moments_ratio_quad_forms or nag_moments_ratio_quad_forms.
3
Description
Let
have an
-dimensional multivariate Normal distribution with mean
and variance-covariance matrix
. Then for a symmetric matrix
and symmetric positive semidefinite matrix
,
g01nbc 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 an
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
d01smc.
4
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
5
Arguments
-
1:
– Nag_OrderType
Input
-
On entry: the
order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by
. See
Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint:
or .
-
2:
– Nag_MomentType
Input
-
On entry: indicates the moments of which function are to be computed.
- (Ratio)
- is computed.
- (Linear with ratio)
- is computed.
- (Quadratic with ratio)
- is computed.
Constraint:
, or .
-
3:
– Nag_IncludeMean
Input
-
On entry: indicates if the mean,
, is zero.
- is zero.
- The value of is supplied in emu.
Constraint:
or .
-
4:
– Integer
Input
-
On entry: , the dimension of the quadratic form.
Constraint:
.
-
5:
– const double
Input
-
Note: the dimension,
dim, of the array
a
must be at least
.
the
th element of the matrix
is stored in
- when ;
- when .
On entry: the by symmetric matrix . Only the lower triangle is referenced.
-
6:
– Integer
Input
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
a.
Constraint:
.
-
7:
– const double
Input
-
Note: the dimension,
dim, of the array
b
must be at least
.
the
th element of the matrix
is stored in
- when ;
- when .
On entry: the by positive semidefinite symmetric matrix . Only the lower triangle is referenced.
Constraint:
the matrix must be positive semidefinite.
-
8:
– Integer
Input
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
b.
Constraint:
.
-
9:
– const double
Input
-
Note: the dimension,
dim, of the array
c
must be at least
when
.
The
th element of the matrix
is stored in
- when ;
- when .
On entry: if
,
c must contain the
by
symmetric matrix
; only the lower triangle is referenced.
If
,
c is not referenced.
-
10:
– Integer
Input
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
c.
Constraint:
if ,
-
11:
– const double
Input
-
Note: the dimension,
dim, of the array
ela
must be at least
- when ;
- otherwise.
On entry: if
,
ela must contain the vector
of length
, otherwise
ela is not referenced.
-
12:
– const double
Input
-
Note: the dimension,
dim, of the array
emu
must be at least
- when ;
- otherwise.
On entry: if
,
emu must contain the
elements of the vector
.
If
,
emu is not referenced.
-
13:
– const double
Input
-
Note: the dimension,
dim, of the array
sigma
must be at least
.
the
th element of the matrix is stored in
- when ;
- when .
On entry: the by variance-covariance matrix . Only the lower triangle is referenced.
Constraint:
the matrix must be positive definite.
-
14:
– Integer
Input
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
sigma.
Constraint:
.
-
15:
– Integer
Input
-
On entry: the first moment to be computed, .
Constraint:
.
-
16:
– Integer
Input
-
On entry: the last moment to be computed, .
Constraint:
.
-
17:
– Integer *
Output
-
On exit: the highest moment computed, . This will be on successful exit.
-
18:
– double
Output
-
On exit: the to moments.
-
19:
– double *
Output
-
On exit: the estimated maximum absolute error in any computed moment.
-
20:
– double
Input
-
On entry: 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 .
-
21:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
- NE_ACCURACY
-
The required accuracy has not been achieved in the integration. An estimate of the accuracy is returned in
abserr.
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_EIGENVALUES
-
The computation to compute the eigenvalues required in the calculation of moments has failed to converge: this is an unlikely error exit.
- NE_ENUM_INT
-
On entry, and .
Constraint: .
- NE_ENUM_INT_2
-
On entry, , and .
Constraint:
if ,
.
- NE_INT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INT_2
-
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
- NE_INTERNAL_ERROR
-
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
See
Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
- NE_MOMENTS
-
Only moments exist, less than , therefore none of the required moments can be computed.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library CL Interface for further information.
- NE_POS_DEF
-
On entry,
sigma is not positive definite.
- NE_POS_SEMI_DEF
-
On entry,
b is not positive semidefinite or is null.
The matrix is not positive semidefinite or is null.
- NE_REAL
-
On entry, .
Constraint: if , .
- NE_SOME_MOMENTS
-
Only some of the required moments have been computed, the highest is given by
lmax.
7
Accuracy
The relative accuracy is specified by
eps and an estimate of the maximum absolute error for all computed moments is returned in
abserr.
8
Parallelism and Performance
g01nbc 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 function. 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 least squares estimate of
,
, is given by
Thus
can be written as a ratio of quadratic forms and its moments computed using
g01nbc. 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.
10.1
Program Text
10.2
Program Data
10.3
Program Results