Skip to content

some MDS and R problems

5 messages · Arnaldo Russo, Jari Oksanen, Gavin Simpson +1 more

#
Hi Arnaldo,

You ask several disjointed question that I don't really follow (esp your
last point about unique), but in response to:
No, nMDS only cares about trying to position points in a k dimensional
space such that the distance between points in this k dimensional space
best represents the rank ordering of the original dissimilarities. If
two samples have 0 dissimilarity, they should occupy the same location
on the plot (in the k dimensional space); one does not influence the
other. Hence simply deleting one of the pair of samples that have zero
distance to one another is appropriate.

As for the code I wrote in the email you cite:

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

We assume Dij is the object containing your distance matrix. In your
example code, it would be

Dij <- as.matrix(dissim1)

for example.

The first line of my code calculates half the smallest observed
dissimilarity. If we break it down, the code in that first line does the
following [there was a missing `]` in the version you quote and probably
in my original]:

Dij[Dij > 0] subsets Dij so that we only work with the dissimilarities
that are positive. This way of indexing the matrix Dij results in a
vector of positive dissimilarities. We then apply the min( ) function to
this vector of positive dissimilarities to return the smallest positive
dissimilarity observed. We then halve this minimum value and store it in
the object minDij.

The second line of my code uses this dissimilarity value (minDij) to
replace the observed dissimilarities in Dij that are less than or equal
to 0.

Hope this is of use. If you still can't get this to work, post back and
let us know.

All the best,

G
On Tue, 2010-06-15 at 08:34 -0300, Arnaldo Russo wrote:

  
    
#
On 15/06/10 15:15 PM, "Gavin Simpson" <gavin.simpson at ucl.ac.uk> wrote:

            
Actually, you *do* lose weights. If two points are identical, all other
points have twice the same contribution to the stress with respect to this
identical pair. There is no way of handling this in isoMDS() which knows no
weights and does not allow duplicate points . The 'zerodist' trick in vegan
metaMDS() is just a kluge to get around this.

The 'zerodist' argument is not used in metaMDS() if you supply your own
dissimilarities. The 'zerodist' works within metaMDSdist() that calculates
dissimilaritiesa and it is not called if you supply your own
dissimilarities. This is not documented in vegan explicitly (I'll see how to
do this). If you have your own dissimilarity structure, you should handle
zero distances by hand before calling metaMDS() or isoMDS().

cheers, Jari Oksanen
#
On Tue, 2010-06-15 at 20:00 +0300, Jari Oksanen wrote:
Ahh, yes. I wasn't thinking about things that way. Taking a step back,
nMDS is about finding a mapping in some low dimensional space. If two
points are exactly similar they should be plotted in the the same
location. In that sense, you don't loose anything by dropping one out,
in the sense that the end result is the location for your two identical
points. That was what I was referring to.

G

  
    
1 day later
#
Arnaldo,

     Given that NMDS operates essentially on rank distances, small 
variations in dissimilarity generally have low impact.  I rarely have 
points with zero dissimilarity on quantitative indices, but it sometimes 
happens on presence/absence based indices.  If you have a dissimilarity 
object named dis, I just do

 > dis[dis==0] <- 0.0001
 > res <- nmds(dis)

Following Jari's argument about the other point's contribution to 
stress, I think fudging one dissimilarity is a better solution than 
dropping out a point

Dave Roberts
Arnaldo Russo wrote: