[R] Principal Component analysis question

Roger Peng rpeng at stat.ucla.edu
Thu Apr 11 01:36:26 CEST 2002


It seems that you have gotten the same answer as the book, with the
exception that the first, fourth and fifth components have different
signs.  I believe that when doing eigenvalue decompositions it's possible
(and I think documented) that you might get a sign flip here and there
depending on your machine. 

It appears that princomp.default() uses La.eigen() and the help page for
La.eigen says:

     `La.eigen' is preferred to `eigen' for new projects, but its
     eigenvectors may differ in sign and (in the asymmetric case) in
     normalization. (They may also differ between methods and between
     platforms.)

Nevertheless, your PCA results will still be valid.

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

On Wed, 10 Apr 2002, Damien Joly wrote:

> I have a question about princomp(mva) that I hope isn't too newbie.
> 
> I used the sample data from Table 1.1 in "Manly (1986/1994) Multivariate 
> Statistical Methods: a primer. Chapman and Hall" on sparrow body 
> measurements.
> 
> I rescaled the data to mean 0 and SD 1, and the covariance matrix is:
> 
>            V1        V2        V3        V4        V5
> V1 1.0000000 0.7349642 0.6618119 0.6452841 0.6051247
> V2 0.7349642 1.0000000 0.6737411 0.7685087 0.5290138
> V3 0.6618119 0.6737411 1.0000000 0.7631899 0.5262701
> V4 0.6452841 0.7685087 0.7631899 1.0000000 0.6066493
> V5 0.6051247 0.5290138 0.5262701 0.6066493 1.0000000
> 
> Now when I call princomp [fun<-princomp(~V1+V2+V3+V4+V5)], I get the 
> following loadings:
> 
>         Comp.1      Comp.2     Comp.3      Comp.4     Comp.5
> V1 -0.4517989 -0.05072137  0.6904702  0.42041399 -0.3739091
> V2 -0.4616809  0.29956355  0.3405484 -0.54786307  0.5300805
> V3 -0.4505416  0.32457242 -0.4544927  0.60629605  0.3427923
> V4 -0.4707389  0.18468403 -0.4109350 -0.38827811 -0.6516665
> V5 -0.3976754 -0.87648935 -0.1784558 -0.06887199  0.1924341
> 
> However, this is in contrast to the results in Manly's book:
> 
>        Comp.1      Comp.2     Comp.3      Comp.4     Comp.5
> V1 0.4517989 -0.05072137  0.6904702 -0.42041399  0.3739091
> V2 0.4616809  0.29956355  0.3405484  0.54786307 -0.5300805
> V3 0.4505416  0.32457242 -0.4544927 -0.60629605 -0.3427923
> V4 0.4707389  0.18468403 -0.4109350  0.38827811  0.6516665
> V5 0.3976754 -0.87648935 -0.1784558  0.06887199 -0.1924341
> 
> Interestingly, when I do the same in SAS, I get:
> 
>         Comp.1      Comp.2     Comp.3      Comp.4     Comp.5
> V1  0.4517989  0.05072137 -0.6904702  0.42041399 -0.3739091
> V2  0.4616809 -0.29956355 -0.3405484 -0.54786307  0.5300805
> V3  0.4505416 -0.32457242  0.4544927  0.60629605  0.3427923
> V4  0.4707389 -0.18468403  0.4109350 -0.38827811 -0.6516665
> V5  0.3976754  0.87648935  0.1784558 -0.06887199  0.1924341
> 
> Finally, when I do it by "hand" in R (i.e., c<-cov(data); e<-eigen(c)), 
> I get a fourth answer:
> 
>            V5          V4         V3          V2         V1
> V1 0.4517989  0.05072137 -0.6904702 -0.42041399 -0.3739091
> V2 0.4616809 -0.29956355 -0.3405484  0.54786307  0.5300805
> V3 0.4505416 -0.32457242  0.4544927 -0.60629605  0.3427923
> V4 0.4707389 -0.18468403  0.4109350  0.38827811 -0.6516665
> V5 0.3976754  0.87648935  0.1784558  0.06887199  0.1924341
> 
> 
> Can anyone point me in the right direction here?  I can email the raw 
> data to anyone if that would help.
> 
> Thank you in advance...
> 
> Damien
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list