g01nb computes the moments of ratios of quadratic forms in Normal variables and related statistics.
Syntax
C# |
---|
public static void g01nb( string dncase, string mean, int n, double[,] a, double[,] b, double[,] c, double[] ela, double[] emu, double[,] sigma, int l1, int l2, out int lmax, double[] rmom, out double abserr, double eps, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g01nb ( _ dncase As String, _ mean As String, _ n As Integer, _ a As Double(,), _ b As Double(,), _ c As Double(,), _ ela As Double(), _ emu As Double(), _ sigma As Double(,), _ l1 As Integer, _ l2 As Integer, _ <OutAttribute> ByRef lmax As Integer, _ rmom As Double(), _ <OutAttribute> ByRef abserr As Double, _ eps As Double, _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g01nb( String^ dncase, String^ mean, int n, array<double,2>^ a, array<double,2>^ b, array<double,2>^ c, array<double>^ ela, array<double>^ emu, array<double,2>^ sigma, int l1, int l2, [OutAttribute] int% lmax, array<double>^ rmom, [OutAttribute] double% abserr, double eps, [OutAttribute] int% ifail ) |
F# |
---|
static member g01nb : dncase : string * mean : string * n : int * a : float[,] * b : float[,] * c : float[,] * ela : float[] * emu : float[] * sigma : float[,] * l1 : int * l2 : int * lmax : int byref * rmom : float[] * abserr : float byref * eps : float * ifail : int byref -> unit |
Parameters
- dncase
- Type: System..::..StringOn 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 .
- mean
- Type: System..::..StringOn entry: indicates if the mean, , is zero.
- is zero.
- The value of is supplied in emu.
Constraint: or .
- n
- Type: System..::..Int32On entry: , the dimension of the quadratic form.Constraint: .
- a
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, n]Note: dim1 must satisfy the constraint:On entry: the by symmetric matrix . Only the lower triangle is referenced.
- b
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, n]Note: dim1 must satisfy the constraint:On entry: the by positive semidefinite symmetric matrix . Only the lower triangle is referenced.Constraint: the matrix must be positive semidefinite.
- c
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, dim2]Note: dim1 must satisfy the constraint:
- if , ;
- otherwise .
Note: the second dimension of the array c must be at least if , and at least otherwise.
- ela
- Type: array<System..::..Double>[]()[][]An array of size [dim1]Note: the dimension of the array ela must be at least if , and at least otherwise.
- emu
- Type: array<System..::..Double>[]()[][]An array of size [dim1]Note: the dimension of the array emu must be at least if , and at least otherwise.
- sigma
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, n]Note: dim1 must satisfy the constraint:On entry: the by variance-covariance matrix . Only the lower triangle is referenced.Constraint: the matrix must be positive definite.
- l1
- Type: System..::..Int32On entry: the first moment to be computed, .Constraint: .
- l2
- Type: System..::..Int32On entry: the last moment to be computed, .Constraint: .
- lmax
- Type: System..::..Int32%On exit: the highest moment computed, . This will be if on exit.
- rmom
- Type: array<System..::..Double>[]()[][]An array of size []On exit: the to moments.
- abserr
- Type: System..::..Double%On exit: the estimated maximum absolute error in any computed moment.
- eps
- Type: System..::..DoubleOn 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 .
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
Let have an -dimensional multivariate Normal distribution with mean and variance-covariance matrix . Then for a symmetric matrix and symmetric positive semidefinite matrix , 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 method 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 .
(1) |
(2) |
(3) |
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 method is based on the method 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
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
Error Indicators and Warnings
Note: g01nb may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface
(LDA, LDB, LDC, LDSIG) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.
On entry, , 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.
- Only some of the required moments have been computed, the highest is given by lmax.
- The required accuracy has not been achieved in the integration. An estimate of the accuracy is returned in abserr.
Accuracy
Parallelism and Performance
None.
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 g01nb. The matrix is given by
and 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 computed and printed.
Example program (C#): g01nbe.cs