[R] Princomp(), prcomp() and loadings()
F.Tusell
etptupaf at bs.ehu.es
Thu Nov 4 09:52:06 CET 2004
El miÃ©, 03-11-2004 a las 17:34, Prof Brian Ripley escribiÃ³:
> 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.
> ...
Mea culpa, even without resort to the example in the help page I
should have thought that differences in the divisor for the
covariance matrix (or using directly the data matrix, as Sundar
Dorai-Raj explained) might account for the small discrepancies.
My apologies.
>
> > 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.
>
Well, the title says: "Rotation Methods for Factor Analysis" and
this was not enough to deter me from using it on PCA generated
loadings. "Factor Analysis" is sometimes meant to include PCA,
even if they are different beasts. Looking at the help page for
"loadings" it also says: "Print Loadings in Factor Analysis",
yet it is meant to be used with PCA loadings as well, as the
later the Description section goes on to saying.
But this is a side question. What I asked in point 2) is why
loadings(princomp(USArrests)) reports as the last four lines
Comp.1 Comp.2 Comp.3 Comp.4
SS loadings 1.00 1.00 1.00 1.00
Proportion Var 0.25 0.25 0.25 0.25
Cumulative Var 0.25 0.50 0.75 1.00
when the eigenvalues are different and so are the amounts of
variance explained by each component. I used "varimax" merely
to produce a different set of loadings and check that the same
behaviour recurred.
> > It looks as if the loadings() function were expecting the eigenvectors
> > to be normalized to the corresponding eigenvalue.
> >
The first line reported by loadings, "SS loadings", is right.
But the loadings matrix returned by princomp has its columns
normalized to 1, while loadings returned by factanal are
not. Hence, with the later, the last two lines are what I
expected, while with the former they are not.
Perhaps the loadings matrices returned by princomp and factanal
should be made of a different class, so loadings (or
print.loadings) treats them differently?
ft.
> > 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.
--
Fernando TUSELL e-mail:
Departamento de EconometrÃa y EstadÃstica etptupaf at bs.ehu.es
Facultad de CC.EE. y Empresariales Tel: (+34)94.601.3733
Avenida Lendakari Aguirre, 83 Fax: (+34)94.601.3754
E-48015 BILBAO (Spain) Secr: (+34)94.601.3740
More information about the R-help
mailing list