g01na computes the cumulants and moments of quadratic forms in Normal variates.

Syntax

C#
public static void g01na(
	string mom,
	string mean,
	int n,
	double[,] a,
	double[] emu,
	double[,] sigma,
	int l,
	double[] rkum,
	double[] rmom,
	out int ifail
)
Visual Basic
Public Shared Sub g01na ( _
	mom As String, _
	mean As String, _
	n As Integer, _
	a As Double(,), _
	emu As Double(), _
	sigma As Double(,), _
	l As Integer, _
	rkum As Double(), _
	rmom As Double(), _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g01na(
	String^ mom, 
	String^ mean, 
	int n, 
	array<double,2>^ a, 
	array<double>^ emu, 
	array<double,2>^ sigma, 
	int l, 
	array<double>^ rkum, 
	array<double>^ rmom, 
	[OutAttribute] int% ifail
)
F#
static member g01na : 
        mom : string * 
        mean : string * 
        n : int * 
        a : float[,] * 
        emu : float[] * 
        sigma : float[,] * 
        l : int * 
        rkum : float[] * 
        rmom : float[] * 
        ifail : int byref -> unit 

Parameters

mom
Type: System..::..String
On entry: indicates if moments are computed in addition to cumulants.
mom="C"
Only cumulants are computed.
mom="M"
Moments are computed in addition to cumulants.
Constraint: mom="C" or "M".
mean
Type: System..::..String
On entry: indicates if the mean, μ, is zero.
mean="Z"
μ is zero.
mean="M"
The value of μ is supplied in emu.
Constraint: mean="Z" or "M".
n
Type: System..::..Int32
On entry: n, the dimension of the quadratic form.
Constraint: n>1.
a
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, n]
Note: dim1 must satisfy the constraint: dim1n
On entry: the n by n symmetric matrix A. Only the lower triangle is referenced.
emu
Type: array<System..::..Double>[]()[][]
An array of size [dim1]
Note: the dimension of the array emu must be at least n if mean="M", and at least 1 otherwise.
On entry: if mean="M", emu must contain the n elements of the vector μ.
If mean="Z", emu is not referenced.
sigma
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, n]
Note: dim1 must satisfy the constraint: dim1n
On entry: the n by n variance-covariance matrix Σ. Only the lower triangle is referenced.
Constraint: the matrix Σ must be positive definite.
l
Type: System..::..Int32
On entry: the required number of cumulants, and moments if specified.
Constraint: 1l12.
rkum
Type: array<System..::..Double>[]()[][]
An array of size [l]
On exit: the l cumulants of the quadratic form.
rmom
Type: array<System..::..Double>[]()[][]
An array of size [dim1]
Note: the dimension of the array rmom must be at least l if mom="M", and at least 1 otherwise.
On exit: if mom="M", the l moments of the quadratic form.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

Let x have an n-dimensional multivariate Normal distribution with mean μ and variance-covariance matrix Σ. Then for a symmetric matrix A, g01na computes up to the first 12 moments and cumulants of the quadratic form Q=xTAx. The sth moment (about the origin) is defined as
EQs,
where E denotes expectation. The sth moment of Q can also be found as the coefficient of ts/s! in the expansion of EeQt. The sth cumulant is defined as the coefficient of ts/s! in the expansion of logEeQt.
The method is based on the method 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

Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDA, LDSIG) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
ifail=1
On entry,n1,
orl<1,
orl>12,
ormom"C" or "M",
ormean"M" or "Z".
ifail=2
On entry,the matrix Σ is not positive definite.
ifail=-9000
An error occured, see message report.
ifail=-6000
Invalid Parameters value
ifail=-4000
Invalid dimension for array value
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

In a range of tests the accuracy was found to be a modest multiple of machine precision. See Magnus and Pesaran (1993b).

Parallelism and Performance

None.

Further Comments

None.

Example

This example is given by Magnus and Pesaran (1993b) and considers the simple autoregression
yt=βyt-1+ut,  t=1,2,n,
where ut is a sequence of independent Normal variables with mean zero and variance one, and y0 is known. The moments of the quadratic form
Q=t=2nytyt-1
are computed using g01na. The matrix A is given by:
Ai+1,i=12,  i=1,2,n-1;Ai,j=0,   otherwise.
The value of Σ can be computed using the relationships
varyt=β2varyt-1+1
and
covytyt+k=βcovytyt+k-1
for k0 and vary1=1.
The values of β, y0, n, and the number of moments required are read in and the moments and cumulants printed.

Example program (C#): g01nae.cs

Example program data: g01nae.d

Example program results: g01nae.r

See Also