nag_rand_corr_matrix (g05pyc) generates a random correlation matrix with given eigenvalues.
, such that
nag_rand_corr_matrix (g05pyc) will generate a random correlation matrix,
, of dimension
, with eigenvalues
The method used is based on that described by
Lin and Bendel (1985)
be the diagonal matrix with values
be a random orthogonal matrix generated by
then the matrix
is a random covariance matrix with eigenvalues
. The matrix
is transformed into a correlation matrix by means of
elementary rotation matrices
. The restriction on the sum of eigenvalues implies that for any diagonal element of
, there is another diagonal element
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
One of the initialization functions nag_rand_init_repeatable (g05kfc)
(for a repeatable sequence if computed sequentially) or nag_rand_init_nonrepeatable (g05kgc)
(for a non-repeatable sequence) must be called prior to the first call to nag_rand_corr_matrix (g05pyc).
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
The maximum error in a diagonal element is given by
The time taken by nag_rand_corr_matrix (g05pyc) is approximately proportional to .
Following initialization of the pseudorandom number generator by a call to
correlation matrix with eigenvalues of
is generated and printed.