[R] Princomp(), prcomp() and loadings()

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Wed Nov 3 17:24:52 CET 2004



F.Tusell wrote:

> In comparing the results of princomp and prcomp I find:
> 
>    1. The reported standard deviations are similar but about 1% from
>       each other, which seems well above round-off error.
>    2. princomp returns what I understand are variances and cumulative
>       variances accounted for by each principal component which are
>       all equal. "SS loadings" is always 1. 
>    3. Same happens after the loadings are varimax-rotated, which in 
>       general should alter the proportions of variance accounted by 
>       each component.
> 
> It looks as if the loadings() function were expecting the eigenvectors
> to be normalized to the corresponding eigenvalue.
> 
> Transcript and version information follow signature. Thank you for any
> clues.
> 

Did you read the corresponding help files?

from ?prcomp:

<quote>
Details:

      The calculation is done by a singular value decomposition of the
      (centered and possibly scaled) data matrix, not by using 'eigen'
      on the covariance matrix.  This is generally the preferred method
      for numerical accuracy.
</quote>

from ?princomp:

<quote>
Details:

      The calculation is done using 'eigen' on the correlation or
      covariance matrix, as determined by 'cor'.  This is done for
      compatibility with the S-PLUS result.  A preferred method of
      calculation is to use 'svd' on 'x', as is done in 'prcomp'.
</quote>

HTH,

--sundar




More information about the R-help mailing list