0

I am experiencing a strange phenomenon. I am doing a PCA on data extracted from GPS coordinates and coinciding bioclimatic variable raster data. I do the analysis in R (64 bit) at my university. Then, when I do the exact same thing at home R (32 bit), the signs of my scores and loadings of PC1 are exactly opposite!

Here is the code (very straightforward):

D = data[,-c(1,2)] #because I don't want to include the lat $ long fields

pca = princomp(D, cor=TRUE) biplot(pca)

Here are the biplots from the two different R's (both version 3.0.2 and the exact same code!)(Sorry I can't post images)

Apart from that they tell the same story (albeit from a different angle), why might this be happening?

Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149
JHK
  • 1
  • 2
    It is not a problem to have opposite sign as well. –  Jul 11 '14 at 16:47
  • 2
    Eigenvectors are only defined up to a scale factor; in particular, the sign can flip without changing the meaning, see [this StackExchange question](http://stats.stackexchange.com/questions/88880/why-do-pca-scores-differ-in-sign). If you want to "fix" this problem, you can write a test to check the sign of the first element of the first eigenvector (for example) and flip the sign appropriately. – Ben Bolker Jul 11 '14 at 18:21
  • Welcome to Stack Overflow! Please consider including a *small* [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so we can better understand and more easily answer your question. In particular, someone could give an example of how to implement the test I suggest in my previous comment. – Ben Bolker Jul 11 '14 at 18:22
  • Ben thanks for the reply, I did see other questions like this, but it seems to happen between different programs and/or different functions. I was curious as to why this would happen though with the exact same function and code?! Also, I wanted to add a link to the entire data set but I could only add two links (here is the link: https://drive.google.com/file/d/0B9p9zSVpNxNldU1xNFhSOTNFN28/edit?usp=sharing) – JHK Jul 11 '14 at 20:55

0 Answers0