Message Boards Message Boards

Calculate component loadings from Principal Components?

Posted 8 years ago

Hi, So I have a set of data that I want to run PCA on. In SPSS this is very simple, and it spits out a clean component matrix. My question is how does one take the output of PrincipalComponents[data,Method->"Correlation"] and get the component matrix?

6 Replies

I do believe it works! Thank you Jim Baldwin. Sorry for the delay in confirmation. I was running something that took a long time on all of my kernels

Posted 8 years ago

Good. I assume you must have access to SPSS and I also assume you'll be trying the same dataset on both SPSS and Mathematica as there are many times subtle but definite differences in algorithms, settings, assumptions, jargon, etc.

POSTED BY: Jim Baldwin

Ok, I greatly appreciate your assistance Jim. I will try this and see if everything works and still makes sense to me

Posted 8 years ago

-0.60157 is what SPSS calls the component loading: the correlation of the first principal component and the first variable.

I haven't added in the "sanitizing" that SPSS does (like only giving the "most important" principal components and putting in blanks where the absolute value of the correlations are less than some threshold. On can add in those features but I'd argue you should only do that (if you're going to do that at all) after looking at all of the output.

POSTED BY: Jim Baldwin

so just to make sure I understand, -0.60157 is the component loading of the first variable for the 1st principal component?

Posted 8 years ago

It's pretty simple, too, in Mathematica. Here's one way:

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}};
pc = PrincipalComponents[data, Method -> "Correlation"];
k = Dimensions[data][[2]];
Table[Correlation[pc[[All, i]], data[[All, j]]], {i, k}, {j, k}] // MatrixForm

Correlations

POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract