naginterfaces.library.stat.moments_​ratio_​quad_​forms

naginterfaces.library.stat.moments_ratio_quad_forms(a, b, sigma, l1, l2, eps, c=None, ela=None, emu=None)[source]

moments_ratio_quad_forms computes the moments of ratios of quadratic forms in Normal variables and related statistics.

For full information please refer to the NAG Library document for g01nb

https://www.nag.com/numeric/nl/nagdoc_28.4/flhtml/g01/g01nbf.html

Parameters
afloat, array-like, shape

The symmetric matrix . Only the lower triangle is referenced.

bfloat, array-like, shape

The positive semidefinite symmetric matrix . Only the lower triangle is referenced.

sigmafloat, array-like, shape

The variance-covariance matrix . Only the lower triangle is referenced.

l1int

The first moment to be computed, .

l2int

The last moment to be computed, .

epsfloat

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.

cNone or float, array-like, shape , optional

Note: the required extent for this argument in dimension 1 is determined as follows: if : ; otherwise: .

If , must contain the symmetric matrix ; only the lower triangle is referenced.

elaNone or float, array-like, shape , optional

If , must contain the vector of length , otherwise is not referenced.

emuNone or float, array-like, shape , optional

If , must contain the elements of the vector .

Returns
lmaxint

The highest moment computed, . This will be if no exception or warning is raised on exit.

rmomfloat, ndarray, shape

The to moments.

abserrfloat

The estimated maximum absolute error in any computed moment.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: if , .

(errno )

On entry, .

Constraint: .

(errno )

On entry, is not positive definite.

(errno )

On entry, is not positive semidefinite or is null.

(errno )

Only moments exist, less than , therefore, none of the required moments can be computed.

(errno )

The matrix is not positive semidefinite or is null.

(errno )

The computation to compute the eigenvalues required in the calculation of moments has failed to converge: this is an unlikely error exit.

Warns
NagAlgorithmicWarning
(errno )

Only some of the required moments have been computed, the highest is given by .

(errno )

The required accuracy has not been achieved in the integration. An estimate of the accuracy is returned in .

Notes

Let have an -dimensional multivariate Normal distribution with mean and variance-covariance matrix . Then for a symmetric matrix and symmetric positive semidefinite matrix , moments_ratio_quad_forms 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 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 quad.dim1_inf.

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, 1993, 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, 1993, The evaluation of moments of quadratic forms and ratios of quadratic forms in Normal variables: Background, motivation and examples, Comput. Statist. (8), 47–55