2
$\begingroup$

I'm trying to get a set of eigenvectors for a correlation matrix, but getting stuck, maybe because I do not properly normalize them. For example, the following code works, in the sense that I get back the original matrix from the decomposition. I also recognize the eigenvector set as a Helmert matrix.

But if I replace 0.7 with 7/10, I no longer get the original matrix back.

What are proper ways to normalize so that it works with 7/10, or even better, with symbolic values?

r = 0.7; k = 3;
Co[i_, j_, n_] := If[i == j, 1, r]; dim = Array[# &, k];
c = Outer[Co[#1, #2, n] &, dim, dim];
MatrixForm[c]
{vals, vecs} = Eigensystem[c];
vv = Transpose[Normalize /@ vecs];
MatrixForm[vv]
sD = DiagonalMatrix[Sqrt[vals]];
vv.sD.Transpose[vv.sD] // MatrixForm

Output of the code

$\endgroup$
2
$\begingroup$

Eigensystem does not orthonormalize the eigenvectors if the matrix consists only of exact input. What worses the situation in this case is that there is an eigenvalue with multiplicity 2 so that the eigenvectors returned this way need not be perpendicular to each other.

k = 3;
r = 7/10;
c = ConstantArray[r, {k, k}] + (1 - r) IdentityMatrix[k];
{vals, vecs} = Eigensystem[c];

So, while we still have the relation

c == Inverse[vecs].(vals vecs)

True

the following does not hold any more with exact input:

c == Transpose[vecs].(vals vecs)

False

You may try Orthogonalize:

vecs1 = Orthogonalize[vecs];
c == Transpose[vecs1].(vals vecs1)

True

This works also with symbolic correlation r and higher dimensions k:

k = 12;
r =.;
c = ConstantArray[r, {k, k}] + (1 - r) IdentityMatrix[k];
{vals, vecs} = Eigensystem[c];
vecs1 = Orthogonalize[vecs];
c == Transpose[vecs1].(vals vecs1) // Simplify

True

| improve this answer | |
$\endgroup$
  • $\begingroup$ I guess it makes parsimonious sense, don't do unless explicitly asked, but I was so engrossed in my statistical application, I haven't even considered non-orthogonality. Documentation is not very clear on this, but my fault, I admit. Thank you so much, you saved me hours of frustration, when I couldn't reproduce a noncentrality vector derived by hand. I also like the way you construct the matrix, that's how I'd do it in R. Will borrow. $\endgroup$ – Mikhail Samuelevich Panikovsky Nov 4 '18 at 16:10
  • $\begingroup$ You're welcome. $\endgroup$ – Henrik Schumacher Nov 4 '18 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.