NAG Library Function Document
nag_cov_to_corr (g02bwc) calculates a matrix of Pearson product-moment correlation coefficients from sums of squares and cross-products of deviations about the mean.
||nag_cov_to_corr (Integer m,
nag_cov_to_corr (g02bwc) calculates a matrix of Pearson product-moment correlation coefficients from sums of squares and cross-products about the mean for observations on
variables which can be computed by a single call to nag_sum_sqs (g02buc)
or a series of calls to nag_sum_sqs_update (g02btc)
. The sums of squares and cross-products are stored in an array packed by column and are overwritten by the correlation coefficients.
be the cross-product of deviations from the mean, for
, then the product-moment correlation coefficient,
is given by
m – IntegerInput
, the number of variables.
r – doubleInput/Output
On entry: contains the upper triangular part of the sums of squares and cross-products matrix of deviations from the mean. These are stored packed by column, i.e., the cross-product between variable and , , is stored in .
: Pearson product-moment correlation coefficients.
These are stored packed by column corresponding to the input cross-products.
fail – NagError *Input/Output
The NAG error argument (see Section 3.6
in the Essential Introduction).
6 Error Indicators and Warnings
On entry, argument had an illegal value.
On entry, .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG
On entry, a variable has zero variance.
The accuracy of nag_cov_to_corr (g02bwc) is entirely dependent upon the accuracy of the elements of array r
nag_cov_to_corr (g02bwc) may also be used to calculate the correlations between parameter estimates from the variance-covariance matrix of the parameter estimates as is given by several functions in this chapter.
A program to calculate the correlation matrix from raw data. The sum of squares and cross-products about the mean are calculated from the raw data by a call to nag_sum_sqs (g02buc)
. The correlation matrix is then calculated from these values.
9.1 Program Text
Program Text (g02bwce.c)
9.2 Program Data
Program Data (g02bwce.d)
9.3 Program Results
Program Results (g02bwce.r)