The function may be called by the names: g02bxc, nag_correg_corrmat or nag_corr_cov.
For observations on variables the one-pass algorithm of West (1979) as implemented in g02buc is used to compute the means, the standard deviations, the variance-covariance matrix, and the Pearson product-moment correlation matrix for selected variables. Suitables weights may be used to indicate multiple observations and to remove missing values. The quantities are defined by:
(a) The means
(b) The variance-covariance matrix
(c) The standard deviations
(d) The Pearson product-moment correlation coefficients
where is the value of the th observation on the th variable and is the weight for the th observation which will be 1 in the unweighted case.
Note that the denominator for the variance-covariance is , so the weights should be scaled so that the sum of weights reflects the true sample size.
Chan T F, Golub G H and Leveque R J (1982) Updating Formulae and a Pairwise Algorithm for Computing Sample Variances Compstat, Physica-Verlag
West D H D (1979) Updating mean and variance estimates: An improved method Comm. ACM22 532–555
1: – IntegerInput
On entry: the number of observations in the dataset, .
2: – IntegerInput
On entry: the total number of variables, .
3: – const doubleInput
On entry: the data must contain the th observation on the th variable, , for and .
4: – IntegerInput
On entry: the stride separating matrix column elements in the array x.
5: – const IntegerInput
On entry: indicates which variables to include in the analysis.
All variables are included in the analysis, i.e., .
, for .
6: – const doubleInput
On entry: , the optional frequency weighting for each observation, with . Usually will be an integral value corresponding to the number of observations associated with the th data value, or zero if the th data value is to be ignored. If wt is NULL then is set to for all .