I have run into an issue with the pca function whereby the outputted PC1 scores are the negative to those expected. To confirm this I tried to recreate an example I found online (<http://setosa.io/ev/principal-component-analysis/)>. I have attached a MatLab file for ease of use. What I have done is:
>> [coeff,score,~,~,~] = pca(Example'); %I use the transpose of data as "Variables1" (17x1) are the variables I want to analyse.*
>> scatter(score(:,1),score(:,2)); >> text(score(:,1)+dx,score(:,2)+dy,Variables2)
*Pretty sure this is worded terribly (sorry)
Above is the the output that I am expecting to find, and below is the ouput that I am getting from the pca function. As you can see the PC2 values are the same but the PC1 values are negative of what expected (Fig above).
Why does this happen? (Not necessary but if you can word this part * better it would be much appreciated for when I have top explain it.)
Thanks in advance.
Best Answer