Why are my PCA eigenvalues (Latent) are completely off?

10 views (last 30 days)
I am trying to determine dimensionality based on eigenvalues (along with other criteria), but the eigenvalues I get from the pca function seem completely off. They are either very small (all below 1) or very big, and do not average to ~1. When I run the PCA on the same data in SPSS, my eigenvalues do seem normal.
Am I running the analysis incorrectly, or should I interpret the eigenvalues that Matlab gives differently?
My data is a matrix of 16 variables (columns) and 61 observations (rows). I have rescaled the data so that each column has a range of 0-1, since the variables in the raw data have wildely different ranges. When I run the rescaled matrix, I get all eigenvalues below 1. With my raw data matrix, eigenvalues have a really big range from ~500 to below 1.
Attached is a csv of my raw data matrix.
I ran the pca as follows:
[COEFF, SCORE, LATENT, TSQUARED, EXPLAINED] = pca(matrix);
I looked at LATENT for the eigenvalues.
I also tried different variations and specifications of the function, which made no difference for the eigenvalues, such as:
[COEFF, SCORE, LATENT, TSQUARED, EXPLAINED] = pca(matrix,'algorithm', 'eig')
%or
[COEFF, SCORE, LATENT, TSQUARED, EXPLAINED] = pca(matrix,'algorithm', 'eig','Centered',false)
%or
[COEFF, SCORE, LATENT, TSQUARED, EXPLAINED] = pca(matrix,'algorithm', 'eig','Centered',false,'Rows','all')
Though I'm pretty sure my rescaling is correct, since it did not give me any problems in SPSS, here is the code:
norm_matrix = raw_matrix;
minx = zeros(1,16);
maxx = zeros(1,16);
for i = 1:16
minx(i) = min(raw_matrix(:,i));
maxx(i) = max(raw_matrix(:,i));
norm_matrix(:,i) = (raw_matrix(:,i)-minx(i))/(maxx(i)-minx(i));
end
Here is an example of my LATENT output:
raw_LATENT =
1.0e+05 *
3.2033
1.4096
0.3762
0.1009
0.0466
0.0223
0.0064
0.0009
0.0002
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
%or
norm_LATENT =
0.4348
0.2526
0.1842
0.0833
0.0702
0.0575
0.0439
0.0380
0.0281
0.0235
0.0154
0.0121
0.0098
0.0074
0.0050
0.0044
0.0034
0.0022
0.0018
0.0013
0.0011
0.0002
0.0000
0

Accepted Answer

Sreeranj Jayadevan
Sreeranj Jayadevan on 17 Nov 2020
Edited: Sreeranj Jayadevan on 20 Nov 2020
The eigenvalues you get after using pca() before rescaling the data is expected to behave in this manner. If you wish to choose the components with highest variances, then you can rescale the eigenvalues. For example, if you have a set of eigenvalues [900,50,25,15,2,2,2,2,0.001,0.0005,0.00001.......], then after rescaling to a range [0,1] (so that you can easily select the components with highest variances), the values will become [0.9,0.05,0.025,0.002.....]. I have not used SPSS for statistical analysis and hence I am not aware of what SPSS outputs as the results.
Check if the parameter 'EXPLAINED' returns the required results. It outputs the percent variability explained by the principal components.
Data standardizing is done before using pca() to eliminate the influence of one feature over another. The normalization method to be followed depends on your data. But in case the features contain outliers, then you may have to normalize the data using a different approach (please refer to normalize() function in MATLAB: https://in.mathworks.com/help/matlab/ref/double.normalize.html), before using pca().
  1 Comment
Iza Korsmit
Iza Korsmit on 20 Nov 2020
Thank you!
You are right, the problem had to do with rescaling! I had simply 'normalized' all my columns to a 0-1 range, thinking that was sufficient. Now I used the normalize() function to rescale, and the eigenvalues make more sense, and are identical to what SPSS and R provide as output.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!