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

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Nov 3 17:34:57 CET 2004


On Wed, 3 Nov 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.

That is explained on the help page!  E.g.

     Note that the default calculation uses divisor 'N' for the
     covariance matrix.

and there is even an example:

     princomp(USArrests, cor = TRUE) # =^= prcomp(USArrests, scale=TRUE)
     ## Similar, but different:
     ## The standard deviations differ by a factor of sqrt(49/50)

>    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.

Hmmm.  Varimax rotation of PCA (not factor analysis) is not supported in
base R, so this is not surprising.  Please do as the posting guide asks,
and read the help page (even its title!) before posting.

> 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.

The best clue is that the help pages are a very useful resource, but need 
to be read as carefully as they were written.

-- 
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-help mailing list