NAG Library Routine Document
G02BWF calculates a matrix of Pearson product-moment correlation coefficients from sums of squares and cross-products of deviations about the mean.
G02BWF 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 G02BUF
or a series of calls to G02BTF
. 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
- 1: M – INTEGERInput
On entry: , the number of variables.
- 2: R() – REAL (KIND=nag_wp) arrayInput/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.
- 3: IFAIL – INTEGERInput/Output
must be set to
. If you are unfamiliar with this parameter you should refer to Section 3.3
in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if
on exit, the recommended value is
. When the value is used it is essential to test the value of IFAIL on exit.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Note: G02BWF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
A variable has a zero variance. All correlations involving the variable with zero variance will be returned as zero.
The accuracy of G02BWF is entirely dependent upon the accuracy of the elements of array R
G02BWF 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 routines 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 G02BUF
. The correlation matrix is then calculated from these values.
9.1 Program Text
Program Text (g02bwfe.f90)
9.2 Program Data
Program Data (g02bwfe.d)
9.3 Program Results
Program Results (g02bwfe.r)