g05py generates a random correlation matrix with given eigenvalues.
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 _ )
public: static void g05py( int n, array<double>^ d, double eps, G05..::..G05State^ g05state, array<double,2>^ c, [OutAttribute] int% ifail )
- Type: System..::..Int32On entry: , the dimension of the correlation matrix to be generated.Constraint: .
- Type: array<System..::..Double>()An array of size [n]On entry: the eigenvalues, , for .Constraints:
- , for ;
- to within eps.
- Type: System..::..DoubleOn entry: the maximum acceptable error in the diagonal elements.Suggested value: .Constraint: (see X02 class).
- 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 .
Given eigenvalues, , such that
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.
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
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.
The maximum error in a diagonal element is given by eps.
The time taken by g05py is approximately proportional to .