An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20080617/ad21a63a/attachment.pl>
manipulating PCA output in R
4 messages · Andrew Halford, David Hewitt, Miltinho Astronauta +1 more
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. ----- David Hewitt Research Fishery Biologist USGS Klamath Falls Field Station (USA)
View this message in context: http://www.nabble.com/manipulating-PCA-output-in-R-tp17877744p17916947.html Sent from the r-sig-ecology mailing list archive at Nabble.com.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20080617/d04b35d5/attachment.pl>
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