[R] prcomp: results with reversed sign in output?

(Ted Harding) ted.harding at wlandres.net
Fri Sep 9 12:04:20 CEST 2011


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>:
> 
>>  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é
>>>
>> --
>> 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

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 09-Sep-11                                       Time: 11:04:16
------------------------------ XFMail ------------------------------



More information about the R-help mailing list