hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_correg_ssqmat_to_corrmat (g02bw)

Purpose

nag_correg_ssqmat_to_corrmat (g02bw) calculates a matrix of Pearson product-moment correlation coefficients from sums of squares and cross-products of deviations about the mean.

Syntax

[r, ifail] = g02bw(m, r)
[r, ifail] = nag_correg_ssqmat_to_corrmat(m, r)

Description

nag_correg_ssqmat_to_corrmat (g02bw) calculates a matrix of Pearson product-moment correlation coefficients from sums of squares and cross-products about the mean for observations on mm variables which can be computed by a single call to nag_correg_ssqmat (g02bu) or a series of calls to nag_correg_ssqmat_update (g02bt). The sums of squares and cross-products are stored in an array packed by column and are overwritten by the correlation coefficients.
Let cjkcjk be the cross-product of deviations from the mean, for j = 1,2,,mj=1,2,,m and k = j,,mk=j,,m, then the product-moment correlation coefficient, rjkrjk is given by
rjk = (cjk)/(sqrt(cjjckk)).
rjk=cjkcjjckk .

References

None.

Parameters

Compulsory Input Parameters

1:     m – int64int32nag_int scalar
mm, the number of variables.
Constraint: m1m1.
2:     r((m × m + m) / 2(m×m+m)/2) – double array
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 jj and kk, kjkj, is stored in r((k × (k1) / 2 + j))r(k×(k-1)/2+j).

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     r((m × m + m) / 2(m×m+m)/2) – double array
Pearson product-moment correlation coefficients.
These are stored packed by column corresponding to the input cross-products.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Note: nag_correg_ssqmat_to_corrmat (g02bw) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

  ifail = 1ifail=1
On entry,m < 1m<1.
W ifail = 2ifail=2
A variable has a zero variance. All correlations involving the variable with zero variance will be returned as zero.

Accuracy

The accuracy of nag_correg_ssqmat_to_corrmat (g02bw) is entirely dependent upon the accuracy of the elements of array r.

Further Comments

nag_correg_ssqmat_to_corrmat (g02bw) 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.

Example

function nag_correg_ssqmat_to_corrmat_example
m = int64(3);
r = [8.75689620235916;
     3.697844992253459;
     1.59053509294466;
     4.070728079123907;
     1.686058157917487;
     1.929668337915273];
[rOut, ifail] = nag_correg_ssqmat_to_corrmat(m, r)
 

rOut =

    1.0000
    0.9908
    1.0000
    0.9903
    0.9624
    1.0000


ifail =

                    0


function g02bw_example
m = int64(3);
r = [8.75689620235916;
     3.697844992253459;
     1.59053509294466;
     4.070728079123907;
     1.686058157917487;
     1.929668337915273];
[rOut, ifail] = g02bw(m, r)
 

rOut =

    1.0000
    0.9908
    1.0000
    0.9903
    0.9624
    1.0000


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013