Dear All, when I'm running a PCA with prcomp(USArrests, scale = TRUE) I get the right principal components, but with the wrong sign infront Rotation: PC1 PC2 PC3 PC4 Murder 0.5358995 -0.4181809 0.3412327 0.64922780 Assault 0.5831836 -0.1879856 0.2681484 -0.74340748 UrbanPop 0.2781909 0.8728062 0.3780158 0.13387773 Rape 0.5434321 0.1673186 -0.8177779 0.08902432 instead of PC1 PC2 PC3 PC4 Murder -0.5358995 0.4181809 -0.3412327 0.64922780 Assault -0.5831836 0.1879856 -0.2681484 -0.74340748 UrbanPop -0.2781909 -0.8728062 -0.3780158 0.13387773 Rape -0.5434321 -0.1673186 0.8177779 0.08902432 what is happening here? any ideas? thanks, Ren?
Hi, If all the signs are switched the PC's are still the same. The principal vectors are along the same axis, only in a different direction. So there is no problem :). hope this helps, Paul On 09/09/2011 09:01 AM, Ren? Mayer wrote:> Dear All, > > when I'm running a PCA with > > prcomp(USArrests, scale = TRUE) > > I get the right principal components, but with the wrong sign infront > > Rotation: > PC1 PC2 PC3 PC4 > Murder 0.5358995 -0.4181809 0.3412327 0.64922780 > Assault 0.5831836 -0.1879856 0.2681484 -0.74340748 > UrbanPop 0.2781909 0.8728062 0.3780158 0.13387773 > Rape 0.5434321 0.1673186 -0.8177779 0.08902432 > > instead of > > PC1 PC2 PC3 PC4 > Murder -0.5358995 0.4181809 -0.3412327 0.64922780 > Assault -0.5831836 0.1879856 -0.2681484 -0.74340748 > UrbanPop -0.2781909 -0.8728062 -0.3780158 0.13387773 > Rape -0.5434321 -0.1673186 0.8177779 0.08902432 > > what is happening here? > any ideas? > > thanks, > Ren? > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
In addition, many PCA packages follow the convention that if the majority of weights are negative for that component, reverse the sign. On 2011-09-10, at 4:00 AM, r-help-request at r-project.org wrote:> The point is that a principal component vector is a solution, > say V, of a matrix equation A%*%V = L*V where A is the matrix > and L is a scalar.. > > Since this equation can be written A%*%(-V) = L*(-V), the > result is indeterminate with respect to its sign. If V is a > solution, so is (-V), and vice versa. It is not a case of > "direction reversal", since neither L nor (-L) has a primary > role -- they are equivalent, and you can adopt either one. > Just make it clear which one you adopt -- or someone else > might think that they disagree! > > You originally wrote "I get the right principal components, > but with the wrong sign in front." You did not get "the wrong > sign" -- both are correct! It may be that you are comparing > your result from R with the result from some other software > (or from a textbook, or whatever) which produced the equivalent > result but with the opposite sign. Again, both are correct. > > If, for some reason, you do not like the sign of the result > you get, then change its sign. > > Hoping this helps, > Ted. > > On 09-Sep-11 09:42:49, Ren? Mayer wrote: >> thanks for pointing out Paul, >> but the thing which is annoying me in the first place IS this >> direction reversal. >> this makes no sense for me >> why could this be? >> >> Zitat von "Paul Hiemstra" <paul.hiemstra at knmi.nl>: >-- Please avoid sending me Word or PowerPoint attachments. See <http://www.gnu.org/philosophy/no-word-attachments.html> -Dr. John R. Vokey