How to related PCA output to the original data?
Show older comments
Hello,
I'm new to PCA and I would like to learn the outcome of pca function. I have read the document and checked others works but I'm a bit confused on how to related the results (wcoeff, latent, explained) to the original data. For example, I'm using the example from the document as below. I understand the (wcoeff) presents the eigenvector vectors. the (latent) presents the eigenvalues. the (explained) is the percentage of the total variance explained by each principal component. NOW, how are all these information are related to the main data which is the ingredients here? how do I know from looking at the results in (explained) that the 55 % is related to which variables or columns in the ingredients matrix?
load hald
[wcoeff,~,latent,~,exp
lained] = pca(ingredients,'VariableWeights','variance')
wcoeff = 4×4
-2.7998 2.9940 -3.9736 1.4180
-8.7743 -6.4411 4.8927 9.9863
2.5240 -3.8749 -4.0845 1.7196
9.1714 7.5529 3.2710 11.3273
latent = 4×1
2.2357
1.5761
0.1866
0.0016
explained = 4×1
55.8926
39.4017
4.6652
0.0406
16 Comments
Adam
on 18 Apr 2019
The 55% is related to the first eigenvector, not to any of the original input variables. You can relate back to your original data via the wcoeff matrix whose rows correspond to the original variables.
Also the 'score' output which is missing from there gives you the mapped data from the original variables onto the new coordinate system of principal components.
Yaser Khojah
on 18 Apr 2019
Edited: Yaser Khojah
on 18 Apr 2019
Adam
on 18 Apr 2019
If you normalise the eigenvectors then the magnitude of each component represents the relative contribution of the original variable of the same index.
Yaser Khojah
on 18 Apr 2019
Edited: Yaser Khojah
on 18 Apr 2019
Adam
on 18 Apr 2019
Yes, each column is a Principal component and each row is the contribution of the original data variable to that Principal component. So the first row of coeff is the contribution of the first input variable to each Principal Component.
Yaser Khojah
on 18 Apr 2019
Edited: Yaser Khojah
on 18 Apr 2019
Adam
on 23 Apr 2019
coeff.^2
will give you the proportions of each original variable for each principal component.
You can then possibly use the latent values to normalise this against the eigenvalues for each of those principal components.
Gabrielle Hedrick
on 23 Aug 2019
Edited: Gabrielle Hedrick
on 23 Aug 2019
I am reading this thread because I am wondering the same thing. Adam, just to make sure I understand your answer, if I have my original data set as a 2074x6, where I have 6 variables (columns) and 2074 observations (rows), and get the following coeff matrix:

It does mean that variable 5 contributes the most to PC1, and variable 1 to PC2, and so on, right?
Adam
on 27 Aug 2019
Yes, those are your eigenvectors down the columns, so consider each one as a vector in 6 dimensional space. Usually they would be normalised, but the relative values still give the relative strengths and variable 5 contributes to that overall vector more than all the others, e.g. ~3.7 times that of variable 1
Gabrielle Hedrick
on 27 Aug 2019
Thank you!
Salma Hassan
on 18 Sep 2019
i don't understand variable 2 has 11.3 it is greater than variable 5
plz explain this...thank you
Adam
on 18 Sep 2019
The variables are in the rows of the coeff matrix. The columns are the principal components eigenvectors.
i have gone through the discussion to understand PCA .I am doing a forecasting problem with neural network and used the below syntax for finding out PCA components for reducing the dimension of training and testing data .
Can i use the output of this command (coeff matrix) as new training and testing data for neural network ad use it for forecasting?
I have 9 input features for forecasting.How can i plot the contribution rates of each feature and prinicpal components against the variance to know the contribution of features and dimension reduction?
kindly help
Paul Gershon
on 20 Nov 2023
What about negative numbers in the a specific column of the PCA matrix? 5/-2 = -2.5 and -5/2 = -2.5 also. How to assess?
Paul Gershon
on 20 Nov 2023
Is the answer to square all numbers in the coeff matrix and then do the division for relative contribution? For example:
PC1 PC2
var1: -2 0.3
var2: 5 3.8
Square it:
PC1 PC2
var1: 4 0.09
var2: 25 14.4
Now relative contribution of var2 to PC1 = 25/4? or is it 25/29? (the denominator is the sum for the column)?
Thanks!
Paul Gershon
on 20 Nov 2023
..Or is the answer not to square the coefficients, but simply to take absolute values because sign simply shows whether the point is pushed negative on the PC axis by the sign of the coefficient, but the sign is irrelevant to magnitude of contribution?
Thanks!
Answers (0)
Categories
Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!