An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20100922/b53a6c3e/attachment.pl>
specifying a "chord" distance matrix in metaMDS
5 messages · Michael Rennie, Jari Oksanen
On 22/09/10 21:42 PM, "Mike Rennie" <mikerennie.r at gmail.com> wrote:
Hi all, I have been running principal coordinates analysis on a "chord" distance matrix (stand normalized for some) using cmdscale. I am trying now to do this with metaMDS but running into some issues. I can execute the code by specifying the distance matrix, and it works fine... obj.nmds<-metaMDS(dist.mat, k=4) FYI, I got the chord distance matrix as follows: dist.mat<-vegdist(decostand(as.matrix(orig.dat), "norm"),"euclidean") I get a solution, and can get at all the site scores in the object dist.mat. However, I also want species scores, which means I need to specify the starting dataset in the command. My question is: how do I specify the chord distance as a command in metaMDS? I've tried a bunch of things that don't work. I know my code should eventually look something like:
Mike, obj.nmds <- metaMDS(decostand(orig.data, "norm"), "euclid", k=4, zerodist="add", autotrans=FALSE)
obj2.nmds<-metaMDS(orig.dat, distance = "something that specifies chord distance", k=4, zerodist="add", autotransform = FALSE, wascores=TRUE) It's the "something that specifies chord distance" that I'm having trouble with. R seems to want a string descriptor there, and I want to give it the call to vegdist but it doesn't look like it wants to let me. If I try and submit the call to vegdist, e.g., obj2.nmds<-metaMDS(orig.dat, distance = vegdist(decostand(as.matrix(orig.dat), "norm"),"euclidean"), k=4, zerodist="add", autotransform = FALSE, wascores=TRUE) I get an error saying "invalid distance method". Surely there's a way around this, but it seems like a coding issue which is why I'm not including example data. Any thoughts? Mike PS- I also gather from reading other posts that I should loop this 50 times or so to make sure I don't end up on some local solution?
If it doesn't converge, continue with obj.nmds <- update(obj.nmds, previous = obj.nmds) cheers, Jari Oksanen
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20100922/7e7661d4/attachment.pl>
On 22/09/10 22:01 PM, "Mike Rennie" <mikerennie.r at gmail.com> wrote:
Thanks Jari- however, when I try this code, it gives me some results for runs with stresses, says I have a solution reached, and then I get an error: Error in cov.wt(x, x.w) : weights must be non-negative and not all zero I'm assuming this is saying I have either zeros or negative values in my distance matrix? Which I shouldn't- when I specify the distance matrix outside of metaMDS, it's all values between 0 and root 2, and I don't see any zero values.
Mike, The error message comes probably from wascores() that finds the species scores after ordination. To be sure, you can say traceback() after getting the error message to see how the error is propagated. I'm sure that the computer is correct if she claims that some of your species abundances are non-negative or that all are zero. If you think otherwise, you're wrong. Don't argue with computers. If this is wascores() like I assume, the error is caused by the transformed abundance data, and not by the dissimilarities. Create transformed data with tmp <- decostand(orig.data, "norm") and see if there are any negative values (min(tmp), any(tmp < 0)), or all zero columns (any(colSums(tmp) <= 0)). Cheers, Jari Oksanen
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20100922/07dc4f5b/attachment.pl>