Re: [R] Vegan R^2 and tau values for metaMDS

From: Gavin Simpson <>
Date: Mon, 14 Apr 2008 21:47:21 +0100

On Mon, 2008-04-14 at 15:38 -0400, Sarah Goslee wrote:
> Dimensionality doesn't matter. 2, 3, 14 will all work.
> What matters is that apparently vegan returns the results in some
> format other than a straight sites x ordination coordinates matrix,
> which is what dist expects. You'll need to convert it to one, possibly
> with as.matrix, or extract the coordinates component from a
> list, or whatever is appropriate for the output of that function from
> that package. The help file should tell you the correct approach
> for getting the nmds configuration itself.

Indeed. It returns a list of class "metaMDS", a list that contains a good deal more information than just the nMDS coordinates.

I'm not sure what you are actually trying to achieve --- is this a correlation between the original distances and the distances on the n-D nMDS axes? If so, this does what you want, using the inbuilt 'dune' data:

example(metaMDS) ## produces 'sol'

Note that the default is to produce a bray-curtis dissimilarity matrix from the input species data. As such, I reproduce this dissimilarity matrix as arg 1 to cor and then take the Euclidean distances of the coordinates on nMDS axes 1:2 (this example is a 2D solution but scales to n-dimensions) as the second argument to cor:

cor(vegdist(dune), dist(sol$points))^2

In this example, the "R^2" is 0.899222

If you already have jaccard for your species data, then substitute this for 'vegdist(dune)' and sol for whatever your nMDS object is called.

However, this assumes a linear relationship between the original distances and the nMDS distances. The relationship need not be linear, just monotonic if I recall the details correctly. stressplot(sol) produces a Shepard diagram of the ordination. The plot shows two different R2 statistics that might be of use. See ?stressplot for details of their calculation.


> Sarah
> On Mon, Apr 14, 2008 at 3:10 PM, stephen sefick <> wrote:
> > the below is a three dimensional solution
> >
> >
> >
> > On Mon, Apr 14, 2008 at 3:09 PM, stephen sefick <> wrote:

> > > cor(x, dist(mds))^2
> > > Error in dist(mds) : (list) object cannot be coerced to 'double'
> > >
> > >
> > >


 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e]
 Gower Street, London          [w]
 UK. WC1E 6BT.                 [w]

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 14 Apr 2008 - 20:53:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Apr 2008 - 21:30:29 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive