简体   繁体   中英

metaMDS {vegan} distances instead of community matrix

The help file of metaMDS {vegan} mentions that one can also use a dist object instead of community data in the comm argument.

So if I run the following, why do I get different results? Am I doing something wrong here and is metaMDS ending up computing dissimilarities of dissimilarities?

library(vegan)
data(varespec)
vare_dist <- vegdist(varespec, method="bray")
vare_mds <- metaMDS(comm = vare_dist, autotransform = FALSE) 
# actually autotransform = FALSE doesn't seem to change the results
plot(vare_mds, type = "t")

vare_mds_2 <- metaMDS(comm = varespec, distance = "bray", k =2)
plot(vare_mds_2, display = "sites", type = "t")

# plots above are different and the stress values below as well
vare_mds$stress; vare_mds_2$stress
# [1] 0.1000211
# [1] 0.1843196

Fallowing this SO question I though that using the autotransform = FALSE would fix the issue. However, I think values are not that extreme to trigger a transformation need, so seems not to apply here. Also this discussion didn't help me much. Specifically, I have a dist object from running unifrac {picante} and I thought I could use it in metaMDS {vegan} . PS: unfortunately I'm not an ecologist and I'm trying my best to fallow the jargon. I can only ask for your extreme patience.

In short, given the same options, metaMDS() called with dissimilarities and community will result in the same model if started from the same random seed (nMDS involves an iterative algorithm using random starting locations).

That you don't use the same random seed for both fits in your example is not the source of the problem here, however. Your two calls are actually resulting in different fits because the input data are different due to the defaults for autotransform with community data and dissimilarities.

autotransform is having a difference as it affects the data that actually gets converted to dissimilarities. Think of it as a pre-processing step, one that you didn't you when you created your dissimilarities. Hence you need to add autotransform = FALSE to the second call, the one with the community data.

If you run the following two calls

set.seed(1)
m1 <- metaMDS(comm = vare_dist, autotransform = FALSE)
set.seed(1)
m2  <- metaMDS(comm = varespec, distance = "bray", autotransform = FALSE)

you'll see that they are the same:

> procrustes(m1, m2)

Call:
procrustes(X = m1, Y = m2) 

Procrustes sum of squares:
8.882e-16

The above shows that the configurations are exactly equivalent up to machine precision, and the stress statistics are equal for both models

> m1$stress
[1] 0.1000211
> m2$stress
[1] 0.1000211

metaMDS() is designed as a wrapper to underlying functions that implement nMDS in a particular way (from ?metaMDS , Details section)

Function metaMDS is a wrapper function that calls several other functions to combine Minchin's (1987) recommendations into one command.

It makes decisions on the basis of the input data. Some of those decisions can'd be made for dissimilarities as, as is the case with autotransform , the are intended to be applied prior to the analysis.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM