corrm, corrvc, corrx

Purpose

Computes an unbiased estimate of a correlation matrix.

Format

cx = corrm(m)
cx = corrvc(vc)
cx = corrx(x)
Parameters:
  • m (KxK moment (x'x) matrix) – A constant term MUST have been the first variable when the moment matrix was computed.
  • vc (KxK variance-covariance matrix) – data or parameters
  • x (NxK matrix) – data
Returns:

cx (PxP correlation matrix) – For corrm(), \(P = K-1\). For corrvc() and corrx(), \(P = K\).

Examples

// Set rnd seed for reproducible results
rndseed   8989;

// Assign x1 and x2
x1 = rndn(3, 3);
x2 = ones(3, 1)~x1;

print "x1 :" x1 ;
print "x2 :" x2;

After the above code, x1 and x2 look like:

x1 :
  0.010555555     -0.045969063       0.12701699
    1.6454828        1.2380373       0.53988699
    1.1556776      -0.53575797       0.14056238
x2 :
    1.0000000      0.010555555     -0.045969063       0.12701699
    1.0000000        1.6454828        1.2380373       0.53988699
    1.0000000        1.1556776      -0.53575797       0.14056238

Continuing from above code,

// Correlation of x1 with x1
print "corrx(x1) :" corrx(x1);

// Correlation of moment = x2'x2
m = x2'x2;
print "corrm(x2'x2) :" corrm(m);

// Correlation of vc of x2
vc = varCovMS(x2'x2);
print "corrvc(varCovMS(x2'x2)):" corrvc(vc);

After the above code,

corrx(x1) :
     1.0000000       0.52196856       0.75039768
    0.52196856        1.0000000       0.95548228
    0.75039768       0.95548228        1.0000000

corrm(x2'x2) :
     1.0000000       0.52196856       0.75039768
    0.52196856        1.0000000       0.95548228
    0.75039768       0.95548228        1.0000000

corrvc(vc):
     1.0000000       0.52196856       0.75039768
    0.52196856        1.0000000       0.95548228
    0.75039768       0.95548228        1.0000000

Remarks

The correlation matrix is the standardized version of the unbiased estimator of the population variance-covariance matrix. It is computed using the moment matrix of deviations about the mean divided by the number of observations minus one \(N - 1\). For the observed correlation/covariance matrix which uses \(N\) rather than \(N - 1\), see corrms() and corrxs().

Source

corr.src

See also

Functions momentd(), corrms(), corrxs(), varCovX(), varCovM()