Need help determining the order of the eigenvectors output from eig
Show older comments
I'm performing PCA on a data set with three variables to reduce correlation but I also need to analyze the eigenvectors output from PCA and compare them. Thus, I need to know which eigenvectors correspond to which of the three variables.
The eig function seems to organize the eigenvalues by decreasing or increasing order which organizes the eigenvectors to not match the order of the variables I input.
Is there anyway to undo the sorting or would I be worth it to make my own eig function?
Also, would it make sense to plot the 3 eigenvectors with the data then to assign the eigenvectors to the data variable which they align with the variation of the most?
Accepted Answer
More Answers (1)
James Tursa
on 25 Aug 2016
0 votes
You might look at this FEX submission by John D'Errico:
2 Comments
Jordan Skaro
on 25 Aug 2016
John D'Errico
on 18 Sep 2025
There is NO specific order of a set of eigenvalues. All you can do is try to use a tool like eigenshuffle, which essentially looks at the sequence of eigenvalues and eigenvectors, to try to put them into a consistent sequence. Consistency from one step to the next is all you can ask for. Will eigenshuffle get it wrong sometimes? Definitely yes. It can be mistaken. How can that happen?
Suppose I give you two sequences, two sets of matrices based on some parameter t. If the sequence of matrices are all very similar, because the parameter t does not change significantly at each step, then eigenshuffle will be very good at what it is trying to do. But if the sequence is very coarse with relatively large steps in the parameter t, then each successive matrix will be very different form the previous one. And now eigenshuffle can get confused.
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!