# [R] Vegan R^2 and tau values for metaMDS

Gavin Simpson gavin.simpson at ucl.ac.uk
Mon Apr 14 22:47:21 CEST 2008

```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

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.

HTH

G

>
> Sarah
>
> On Mon, Apr 14, 2008 at 3:10 PM, stephen sefick <ssefick at gmail.com> wrote:
> > the below is a three dimensional solution
> >
> >
> >
> >  On Mon, Apr 14, 2008 at 3:09 PM, stephen sefick <ssefick at gmail.com> 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] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

```