# 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 corrm() and corrx() computes the population correlation matrix. For the sample correlation matrix, use corrm() or corrx().

corr.src