与其他轴相比,在 nMDS 中没有与每个轴相关的方差百分比
主成分方法,如 PCA、CA、PCoA (= MDS)。
我引用勒让德和勒让德 2012 年:
与基于特征向量的方法 PCA、PCoA 或 CA 不同,nMDS 计算不会最大化与排序的各个轴相关的可变性
NMDS 的目的是在几个维度上保持和表示观察的顺序
而其他方法的目标更多是保持观察之间的精确距离,
并找到使解释方差最大化的原始轴的组合。
您可以使用 2 维检查和可视化表示的质量
“Shepard”图表示在 2 维上的距离
k维空间中的原始距离。
这是一个比较a的2维表示质量的示例
nMDS 和基于 Bray-Curtis 距离的 MDS (PCoA)。
library(vegan)
data(dune)
nMDS <- metaMDS(dune, distance = "bray", k = 2)
MDS <- cmdscale(vegdist(dune, method = "bray"), k = 2, eig = T, add = T )
MDS 轴解释的方差百分比
round(MDS$eig*100/sum(MDS$eig),1)
#> [1] 30.3 18.7 9.5 8.0 6.6 5.5 4.3 3.0 2.7 2.4 2.2 1.7 1.6 1.5
#> [15] 0.8 0.6 0.4 0.1 0.0 0.0
谢泼德图
# x11(width = 18/2.54, height = 9/2.54)
par(mfrow = c(1,2), mar = c(3.5,3.5,3,1), mgp = c(2, 0.6, 0), cex = 0.8, las = 1)
spear <- round(cor(vegdist(dune, method = "bray"), dist(nMDS$points), method = "spearman"),3)
plot(vegdist(dune, method = "bray"), dist(nMDS$points), main = "Shepard diagram of nMDS",
xlab = "True Bray-Curtis distance", ylab = "Distance in the reduced space")
mtext(line = 0.1, text = paste0("Spearman correlation = ", spear), cex = 0.7)
spear <- round(cor(vegdist(dune, method = "bray"), dist(MDS$points), method = "spearman"),3)
plot(vegdist(dune, method = "bray"), dist(MDS$points), main = "Shepard diagram of MDS",
xlab = "True Bray-Curtis distance", ylab = "Distance in the reduced space")
mtext(line = 0.1, text = paste0("Spearman correlation = ", spear), cex = 0.7)
要确定您需要多少尺寸,您可以将应力绘制为
维数。请注意,与传统的碎石图相比,每个条形图
不代表与每个轴相关的方差,而是代表总应力(一个函数
所有维度的 d 和 d_hat 之间的平方差。例如,“3Dim”栏
表示 3 维解的应力,而不是与第 3 轴相关的应力...
此处对大于 2 维的维度表示的改进很低。
n = 10
stress <- vector(length = n)
for (i in 1:n) {
stress[i] <- metaMDS(dune, distance = "bray", k = i)$stress
}
names(stress) <- paste0(1:n, "Dim")
# x11(width = 10/2.54, height = 7/2.54)
par(mar = c(3.5,3.5,1,1), mgp = c(2, 0.6, 0), cex = 0.8, las = 2)
barplot(stress, ylab = "stress")
由reprex package (v0.2.0) 于 2018 年 3 月 11 日创建。