Skip to content
Prev 273254 / 398506 Next

distance coefficient for amatrix with ngative valus

Comments inline:

On Mon, Oct 3, 2011 at 11:27 PM, dilshan benaragama
<benaragamad at yahoo.com> wrote:
No, you did not state your problem. I have replied to everything you
have actually included to this point. Admittedly, I have failed to
reply to things you did not say...
This is now the 7th email in this chain. You should mention the
packages and functions you are using in the FIRST email of the chain.
This is mentioned in the posting guide which you apparently have still
not yet read.
They all work for any data I put in. This is perhaps when that minimal
working example, which you also should have included, is necessary.
The append at the end of each of the 7 emails in this chain that tells
you to read the posting guide also asks for this, as did I explicitly.
No, they each give warnings. Warnings are not errors. They are
warnings and they say "warning". Perhaps unsurprisingly, errors say
"error". If you are using an old version of vegan that throws an
error, you should always update before seeking help.Not surprisingly,
a certain document suggests this.
Actually read the warning message: it warns you that you have given
negative data to an ecological function and suggests this might be a
point you look into as this usually suggests a user-end problem. It
does not fail to work in any sense of the word as evidence by the
output of distances. If  negative data is nonsense, you should heed
this warning; if you know its not, disregard it.

More importantly, as I said in my initial response, any distance
metric worth its salt is translation invariant. To wit,

x <- matrix(rnorm(50),5)

d1 = vegdist(x, method="gower")
d2 = vegdist(x + abs(min(x))*3, method="gower")

all.equal(as.numeric(d1), as.numeric(d2))
TRUE

In fairness, I'll admit this does not seem to work for the bray
distance. I am not an ecologist and I do not know why this would be --
it does leave me somewhat confused as to what sort of space motivates
the bray metric, but that's a discussion for another time and place --
but the function still returns a valid dist object for both d1 and d2.
You will note that I include the r-help list on each email on this
chain while you have not; this is mentioned in the posting guide.
Would you care to elaborate further as to what the actual problem
entails, with a minimal working example?

More generally, might I suggest you learn how these metrics work and
then apply the most appropriate one rather than groping blindly after
something solely on the criterion of it being non-Euclidean. If you
need other metrics, look into the various p-norms, all of which are
implemented directly in R by way of the dist() function as are a few
other norms with which I am not immediately familiar.

Regards,

Michael Weylandt