Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a list "xlsf" with 6 columns and 1200 rows for PCA analysis. The PrincipalComponents[xlsf] gives the following:

"The principal components of matrix are linear transformations of the original columns into uncorrelated columns arranged in order of decreasing variance"

How do I obtain the transformations performed on columns by Mathematica?

share|improve this question
1  
Use SingularValueDecomposition. –  Szabolcs Jun 17 at 16:02
1  
Or KarhunenLoeveDecomposition –  Oleksandr R. Jun 17 at 18:59

1 Answer 1

PrincipalComponents is based on SingularValueDecomposition. Below I'll show what it does:

This is some sample data from the docs:

data = {{13.2, 200, 58, 21.2}, {10, 263, 48, 44.5}, {8.1, 294, 80, 
    31}, {8.8, 190, 50, 19.5}, {9, 276, 91, 40.6}, {7.9, 204, 78, 
    38.7}, {3.3, 110, 77, 11.1}, {5.9, 238, 72, 15.8}, {15.4, 335, 
    80, 31.9}, {17.4, 211, 60, 25.8}};

Let's centre it first:

data2 = # - Mean[data] & /@ data;

Then compute the SVD of the centred data:

{u, s, v} = SingularValueDecomposition[data2];

Now Transpose[v] is the rotation that PrincipalComponents applies to each row.

share|improve this answer
    
what happens if I do not center the data? –  denfromufa Jun 17 at 21:49
1  
@denfromufa Do you understand the mathematics behind PCA? –  Szabolcs Jun 17 at 21:55
    
now I understand that PCA can be obtained by doing SVD to centralized data: math.stackexchange.com/questions/3869/… –  denfromufa Jun 18 at 22:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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