[R] Beginners Question

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Jun 3 13:32:32 CEST 2007


Please _do_ read the message.  Only you are talking about 'doubled 
values': the error report is about 'zero or negative distance'

What the help page says is

        d: distance structure of the form returned by 'dist', or a full,
           symmetric matrix.  Data are assumed to be dissimilarities or
           relative distances, but must be positive except for
           self-distance.  Both missing and infinite values are allowed.

and you are not supplying such a structure.

In any case, you seem to be trying to do isoMDS on Euclidean distances 
from a 1D array.  There is no point in doing any form of MDS on Euclidean 
distances unless dimension reduction is involved, since otherwise the 
distances can be represented exactly.

I suggest you take some statistical advice on your problem, as your issues 
do not seem to be with R.


On Sun, 3 Jun 2007, Thomas Zastrow wrote:

> Thank you very much for your answer.
>
> Isn't it possible to tell the isoMDS function that it should ignore doubled 
> values with the same value? Or is there a possible to delete all the doubled 
> values from the x.dist?
>
> Best regards,
>
> Tom
>
>
> Prof Brian Ripley schrieb:
>> That two distances are the same is *not* what the message says.
>> 
>> You can't just look at elements of the results of dist() and simply relate 
>> them back to object numbers.  Try as.matrix(x.dist) for a human-readable 
>> form.
>> 
>> 
>
>> On Fri, 1 Jun 2007, Thomas Zastrow wrote:
>> 
>>> Dear all,
>>> 
>>> I'm completely new to R and at first I must say that it is a great 
>>> program!
>>> 
>>> But I have a problem with the function isoMDS from the MASS package. I
>>> have this code which I load with source() from a file:
>>> 
>>> x <- c(163.59514923926784, 150.01448475257115, ...... {here are some
>>> more values})
>>> x.sort <- sort(x)
>>> x.dist <- dist(x.sort)
>>> library(MASS)
>>> x.mds <- isoMDS(x.dist)
>>> plot(x.mds$points, type="n")
>>> text(x.mds$points, labels=as.character("x"))
>>> 
>>> The problem is in the line where the isoMDS function is applied: I got
>>> the error:
>>> 
>>> Fehler in isoMDS(x.dist) : zero or negative distance between objects 9
>>> and 10
>>> 
>>> When I look at values 8 and 9 of x.dist, I see that they have the same
>>> values (I'm not wrong, it's values of 8 and 9 and not 9 and 10):
>>> 
>>> x.dist[8:9]
>>> [1] 39.8214  39.8214
>>> 
>>> So, just to give'm a try, I changed the value of x.dist[8]:
>>> 
>>> x.dist[8] <- c(39.7)
>>> 
>>> Now, there are defintitely different values in this part of x.dist:
>>> 
>>> x.dist[7:10]
>>> [1] 39.69898     39.70000      39.82140      39.98892
>>> 
>>> But when I start isoMDS again, I got again the error:
>>> 
>>> x.mds <- isoMDS(x.dist)
>>> Fehler in isoMDS(x.dist) : zero or negative distance between objects 9
>>> and 10
>>> 
>>> 
>>> So, where's my error?
>>> 
>>> Thank you!
>>> 
>>> Best,
>>> 
>>> Tom
>>> 
>>> 
>>> 
>> 
>
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list