g05py generates a random correlation matrix with given eigenvalues.
Syntax
C# |
---|
public static void g05py( int n, double[] d, double eps, G05..::..G05State g05state, double[,] c, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g05py ( _ n As Integer, _ d As Double(), _ eps As Double, _ g05state As G05..::..G05State, _ c As Double(,), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g05py( int n, array<double>^ d, double eps, G05..::..G05State^ g05state, array<double,2>^ c, [OutAttribute] int% ifail ) |
F# |
---|
static member g05py : n : int * d : float[] * eps : float * g05state : G05..::..G05State * c : float[,] * ifail : int byref -> unit |
Parameters
- n
- Type: System..::..Int32On entry: , the dimension of the correlation matrix to be generated.Constraint: .
- d
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: the eigenvalues, , for .Constraints:
- , for ;
- to within eps.
- eps
- Type: System..::..DoubleOn entry: the maximum acceptable error in the diagonal elements.Suggested value: .Constraint: (see X02 class).
- g05state
- Type: NagLibrary..::..G05..::..G05StateAn Object of type G05.G05State.
- c
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, n]Note: dim1 must satisfy the constraint:On exit: a random correlation matrix, , of dimension .
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
Given eigenvalues,
, such that
and
g05py will generate a random correlation matrix,
, of dimension , with eigenvalues .
The method used is based on that described by
Lin and Bendel (1985). Let be the diagonal matrix with values and let be a random orthogonal matrix generated by
g05px then the matrix is a random covariance matrix with eigenvalues . The matrix is transformed into a correlation matrix by means of elementary rotation matrices such that . The restriction on the sum of eigenvalues implies that for any diagonal element of , there is another diagonal element . The are constructed from such pairs, chosen at random, to produce a unit diagonal element corresponding to the first element. This is repeated until all diagonal elements are to within a given tolerance .
The randomness of should be interpreted only to the extent that is a random orthogonal matrix and is computed from using the which are chosen as arbitrarily as possible.
One of the initialization methods (G05KFF not in this release) (for a repeatable sequence if computed sequentially) or (G05KGF not in this release) (for a non-repeatable sequence) must be called prior to the first call to g05py.
References
Lin S P and Bendel R B (1985) Algorithm AS 213: Generation of population correlation on matrices with specified eigenvalues Appl. Statist. 34 193–198
Error Indicators and Warnings
Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface
(LDC) In these
cases, an error in another parameter has usually caused an incorrect value to be inferred.
On entry, .
On entry, for some , or .
On entry, .
On entry, state vector was not initialized or has been corrupted.
Accuracy
The maximum error in a diagonal element is given by
eps.
Parallelism and Performance
None.
Further Comments
The time taken by g05py is approximately proportional to .