[R] Non-metric multidimensional scaling (NMDS) help

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Jan 12 20:45:21 CET 2010


On Tue, 2010-01-12 at 10:28 -0800, kellys17 wrote:
> Hi,
> 
>  I am currently working on some data and feel that NMDS would return an
> excellent result. With my current data set however I have been experiencing
> some problems and cannot carry out metaMDS. I have tried with a few smaller
> data sets which I created for practice sake and this has worked fine.

What were the errors/warnings you received that led you to this
conclusion? Please read the posting guide:

http://www.R-project.org/posting-guide.html

before replying to the list as from the above, there is almost no way
that we can help you.

> 
>  I think it is the set up of my data set that is causing me trouble. I have
> 18 columns and 18 rows, as needed for the n x n matrix. However, within the
> data set I have a lot of zeros, i.e. more than just the zeros where column B
> meets row B. Do I need to get rid of these excess zeros in order for metaMDS
> to work?

You can provide a dissimilarity matrix *or* a community matrix to
metaMDS. If the latter, it will compute the dissimilarity for you (via
metaMDSdist() ) and you can avail yourself of the argument 'zerodist' to
that function --- see ?metaMDS for the arguments.

>From the above, I deduce that the error from metaMDS is along the lines
of:

...zero or negative distance between objects X and Y...

which is because isoMDS can't work with samples that have zero
dissimilarity to one another. Indeed - by definition they should be
placed in the same location so why ordinate them at all, just use one of
the samples.

Is your matrix your own dissimilarity matrix? If so, is there some
reason you can't use the ones provided in vegan or metaMDS?

If there is a good reason, and you want to include all samples, then
you'll need to come up with a means for handling them. metaMDSdist allow
you to add a small value to the zero dissimilarities. The details are in
the code, but effectively all zero distances are replaced by half the
smallest non zero distance. You could do a similar replacement yourself
if you feel this is warranted and/or justified.

minDij <- min(Dij[Dij > 0) / 2
Dij[Dij <= 0] <- minDij

Will do this replacement if Dij is your matrix (replace Dij with
whatever the name of your matrix is). Then supply the new matrix to
metaMDS.

For most applications I have needed nMDS for, I would delete the samples
with duplicated species composition rather than add ad hoc amounts to
samples just to get the software to produce a result.

HTH

G

> 
>  Any help is much appreciated,
> 
>  Seán Kelly.
>  
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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