[Rd] Principal Components Analysis (PR#8320)

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Thu Nov 17 08:15:34 CET 2005


Please do RTFM:  ?princomp says

Note:

      The signs of the columns of the loadings and scores are arbitrary,
      and so may differ between different programs for PCA, and even
      between different builds of R.

and ?prcomp has a similar comment.  Equally, the signs of eigenvectors are 
arbitrary, and ?eigen says

           Recall that the eigenvectors are only defined up to a
           constant: even when the length is specified they are still
           only defined up to a scalar of modulus one (the sign for real
           matrices).

If you don't know why these are true, please ask your advisors for help.


On Thu, 17 Nov 2005 sarkar at mail.utexas.edu wrote:

> Full_Name: Sahotra Sarkar
> Version: 2.2.0
> OS: Windows XP Professional
> Submission from: (NULL) (146.6.130.180)
>
>
> The following two commands should give the same results for the eigenvectors but
> do not (there is a sign reversal for the first one):
>
>> summary(princomp(bumpus),loading = TRUE)
> Importance of components:
>                          Comp.1    Comp.2     Comp.3      Comp.4     Comp.5
> Standard deviation     6.2801653 2.4285636 1.13995042 0.560733747 0.03458915
> Proportion of Variance 0.8399662 0.1256084 0.02767525 0.006696272 0.00002548
> Cumulative Proportion  0.8399662 0.9655746 0.99324988 0.999946156 0.99997164
>                             Comp.6       Comp.7       Comp.8       Comp.9
> Standard deviation     3.025628e-02 1.405339e-02 1.147326e-02 9.339938e-03
> Proportion of Variance 1.949623e-05 4.206121e-06 2.803451e-06 1.857837e-06
> Cumulative Proportion  9.999911e-01 9.999953e-01 9.999981e-01 1.000000e+00
>
> Loadings:
>   Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8 Comp.9
> V1  0.497  0.851  0.171
> V2  0.853 -0.515
> V3  0.149  0.103 -0.965  0.189
> V4               -0.180 -0.981
> V5                             -0.288         0.568  0.327  0.693
> V6                             -0.399         0.565  0.154 -0.705
> V7                             -0.867        -0.475 -0.107
> V8                                            0.352 -0.926  0.118
> V9                                     0.994
>> eigen(cov(bumpus))
> $values
> [1] 3.973263e+01 5.941610e+00 1.309113e+00 3.167514e-01 1.205271e-03
> 9.222233e-04
> [7] 1.989606e-04 1.326107e-04 8.788062e-05
>
> $vectors
>              [,1]          [,2]         [,3]         [,4]          [,5]
> [1,] -0.496897319  0.8505093640  0.171388489  0.018744742 -0.0002708851
> [2,] -0.852790441 -0.5152155401  0.081515933  0.025301353  0.0031275939
> [3,] -0.149011771  0.1032588064 -0.965116017  0.188813583  0.0029039523
> [4,] -0.059981091  0.0228574697 -0.180065518 -0.981007482  0.0301789269
> [5,] -0.002474454 -0.0009781164 -0.003402721 -0.011404980 -0.2884751568
> [6,] -0.002255070 -0.0003234929 -0.002776659 -0.014386855 -0.3990284747
> [7,] -0.003505091 -0.0005603692 -0.006526439 -0.022328724 -0.8671382015
> [8,] -0.001124313  0.0005858447 -0.003031985 -0.006957916 -0.0674635788
> [9,] -0.003810707  0.0004531193 -0.006127501 -0.009908937 -0.0122192249
>              [,6]          [,7]          [,8]          [,9]
> [1,] -0.001028476  1.638253e-06  0.0004887328 -0.0003561342
> [2,] -0.002350593 -8.313864e-04 -0.0003929312  0.0005026715
> [3,] -0.004636198  8.031165e-05  0.0015963693  0.0010649875
> [4,] -0.011239114 -5.568762e-03  0.0035062479  0.0003785351
> [5,]  0.083901242  5.675807e-01  0.3265320650 -0.6934139460
> [6,]  0.032231827  5.646388e-01  0.1541661011  0.7049350072
> [7,] -0.058318858 -4.748060e-01 -0.1070487286 -0.0849487969
> [8,]  0.014813290  3.516922e-01 -0.9260185177 -0.1182046449
> [9,]  0.994055719 -9.937481e-02 -0.0249932592  0.0324567705
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list