[R-sig-eco] manipulating PCA output in R
Jari Oksanen
jari.oksanen at oulu.fi
Tue Jun 17 22:54:00 CEST 2008
Quoting David Hewitt <dhewitt37 at gmail.com>:
>
>
>
>> I am doing a PCA on a single dataset and want to control which variables
>> are plotted as vectors on the biplot produced. How can I first determine
>> which variables are most important in producing the ordination and how do
>> I then control what variables are included as vectors in the biplot?
>>
>
> I'm not sure what you mean by "most important", but I think you want to know
> the loadings on the components, which you can retrieve easily from the
> object returned by princomp or prcomp (it depends on which function you
> used). See ?prcomp and ?princomp. With prcomp the rotations are printed by
> default. With princomp, use loadings(princomp.object).
>
> Not sure about suppressing certain arrows (variables) from the plot.
>
The question was vague, but I assume it concerned prcomp (or princomp)
and biplot.prcomp (or biplot.princomp). Selecting variables is
particularly easy in these functions, because they take one-sided
model formulae. To pick vars x3, x7 and x9 from a data frame df you
just write prcomp(~ x3 + x7 + x9, data=df). However, there seems not
be an easy way of omitting variables used in prcomp (or princomp) in
biplot functions (there may be this option if you use rda function in
prcomp but not for arrows, only for points or text, but I don't care
to check the documentation). Since you ask this, I think you'd rather
want to have factor analysis than PCA. It may be good to consult a
statistician or a book on this issues.
Best wishes, Jari Oksanen
More information about the R-sig-ecology
mailing list