[R] Factor Loadings in Vegan's PCA
Gavin Simpson
gavin.simpson at ucl.ac.uk
Thu Jul 1 14:00:37 CEST 2010
On Wed, 2010-06-30 at 18:02 -0300, afsouza at unisinos.br wrote:
> Hi all,
>
> I am using the vegan package to run a prcincipal components analysis
> on forest structural variables (tree density, basal area, average
> height, regeneration density) in R.
>
> However, I could not find out how to extract factor loadings
> (correlations of each variable with each pca axis), as is straightforwar
> in princomp.
>
> Do anyone know how to do that?
It is easier than I thought when I answered your Q on ECOLOG-L the other
day ;-)
If ord is your fitted PCA ordination done using rda() from vegan, then
we just need to extract the *unscaled* species scores to get the same
things as is given by loadings() on a princomp ordination or the
$rotation from a prcomp ordination
require(vegan)
foo <- princomp(USArrests, cor = TRUE)
FOO <- prcomp(USArrests, scale = TRUE)
bar <- rda(USArrests, scale = TRUE)
loadings(foo)
with(FOO, rotation)
scores(bar, choices = 1:4, display = "species", scaling = 0)
> Moreover, do anyone knows a function r package that produces
> rotated-pca and biplots? Most packages I found did only one of these
> tasks (princomp, psych, vegan).
I'm not sure what you mean here; biplot() is a convenience wrapper
method for rda() ordinations that produces a biplot of the PCA
ordination. The plot methods for rda() objects allow you to create a
biplot by hand if you want or just plot one set of scores. The biplot()
method just tries to simplify this process.
As is typical in ecology though, we want to scale sites or species to
best represent relationships between sites or between species, so you
need to choose the scaling most appropriate for your data/question.
Scaling = 3 is usually a good compromise. More about scalings in vegan
and prcomp/princomp can be found in the design decisions vignette:
http://cran.r-project.org/web/packages/vegan/vignettes/decision-vegan.pdf
Can you explain what you mean by "rotated-pca"? PCA is just a rotation
of the data and that is what vegan does and plots. This may just be an
issue of terminology, so if you can explain or point me to a reference
that describes what you want, I'll look into it some more.
HTH
G
>
> Thanks a lot,
>
> Alexandre
>
>
>
> Dr. Alexandre F. Souza
> Programa de Pós-Graduação em Biologia: Diversidade e Manejo da Vida
> Silvestre
> Universidade do Vale do Rio dos Sinos (UNISINOS)
> Av. UNISINOS 950 - C.P. 275, São Leopoldo 93022-000, RS - Brasil
> Telefone: (051)3590-8477 ramal 1263
> Skype: alexfadigas
> afsouza at unisinos.br
> http://www.unisinos.br/laboratorios/lecopop
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list