[R-sig-eco] pearson correlation with axes of NMDS or capscale

Jari Oksanen jari.oksanen at oulu.fi
Wed Aug 18 10:31:23 CEST 2010


On Wed, 2010-08-18 at 11:14 +0300, Jari Oksanen wrote:
> On Wed, 2010-08-18 at 09:50 +0200, Opdekamp Wout wrote:
> > Hi all,
> > 
> > In Primer/permanova+ it is possible to get the pearson correlation of a
> > species with the axes of NMDS or capscale. Is it possible to extract or
> > calculate these as well based on the output from metaMDS() or capscale
> > (), both from the vegan-package?
> 
> Wout,
> 
> Short answer: Yes.
> 
> A bit longer answer: you shouldn't do this for metaMDS (or NMDS in
> general) since there the orientation of axes is random and axes do not
> have a special meaning.
> 
> A longer answer or how to do this. You may paste the following to an R
> window (explanations are commented):
> 
> ### BEGIN R
> ## NMDS
> library(vegan)
> data(dune)
> m <- metaMDS(dune)
> cor(dune, scores(m, dis="si"))
> ## capscale, copying the previous method, but 4 axes
> m <- capscale(dune ~ 1)
> cor(dune, scores(m, dis="si", choices=1:4)
> ## capscale, the direct way re-using the previous result
> scores(m, dis="sp", scaling=-2, const = sqrt(nrow(dune)-1)))
> ### END
> 
A small addition to the example above: While the example works correctly
for unconstrained case, you must modify the first method to use "lc"
scores instead of "si" scores to get the results that are identical to
the second method of getting the "sp" scores directly:

## modification for constrained ordination
m <- capscale(dune ~ ., dune.env, dis="bray")
s1 <- cor(dune, scores(m, dis="lc"))
s2 <- scores(m, dis="sp", scaling=-2, const = sqrt(nrow(dune)-1))
## checks
range(s1-s2) # equal within numerical accuracy
all.equal(s1, s2, check.attributes=FALSE)

Cheers, Jari Oksanen



More information about the R-sig-ecology mailing list