R 中 NMDS 解释的累积方差
Cumulative variance explained for NMDS in R
有没有一种方法可以使用函数 metaMDS 确定从 NMDS 对象解释的累积方差(度量拟合或 R^2m)?压力、分数、分数的对象 returns 值,但我没有看到差异。该函数来自 vegan 包并执行非度量多维缩放。
metaMDS(comm, distance = "bray", k = 2, try = 20, trymax = 20,
engine = c("monoMDS", "isoMDS"), autotransform =TRUE,
noshare = (engine == "isoMDS"), wascores = TRUE, expand = TRUE,
trace = 1, plot = FALSE, previous.best, ...)
我读到 R^2 是 1-总应力?
感谢任何建议。
与其他相比,nMDS 中的每个轴没有相关方差百分比
主成分法,如 PCA、CA、PCoA (= MDS)。
我引用 Legendre & Legendre 2012 :
Contrary to PCA, PCoA, or CA, which are eigenvector-based methods, nMDS calculations do not maximize the variability associated with individual axes of the ordination
NMDS 的目的是在几个维度上保存和表示观测值的顺序
而其他方法的 objective 更多是为了保持观察之间的确切距离,
并找到使解释方差最大化的原始轴组合。
您可以检查和可视化二维表示的质量
"Shepard" 表示排序的二维距离的图表
k维的原始距离space.
这是一个示例,用于比较 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-03-11。
有没有一种方法可以使用函数 metaMDS 确定从 NMDS 对象解释的累积方差(度量拟合或 R^2m)?压力、分数、分数的对象 returns 值,但我没有看到差异。该函数来自 vegan 包并执行非度量多维缩放。
metaMDS(comm, distance = "bray", k = 2, try = 20, trymax = 20,
engine = c("monoMDS", "isoMDS"), autotransform =TRUE,
noshare = (engine == "isoMDS"), wascores = TRUE, expand = TRUE,
trace = 1, plot = FALSE, previous.best, ...)
我读到 R^2 是 1-总应力?
感谢任何建议。
与其他相比,nMDS 中的每个轴没有相关方差百分比 主成分法,如 PCA、CA、PCoA (= MDS)。
我引用 Legendre & Legendre 2012 :
Contrary to PCA, PCoA, or CA, which are eigenvector-based methods, nMDS calculations do not maximize the variability associated with individual axes of the ordination
NMDS 的目的是在几个维度上保存和表示观测值的顺序 而其他方法的 objective 更多是为了保持观察之间的确切距离, 并找到使解释方差最大化的原始轴组合。
您可以检查和可视化二维表示的质量
"Shepard" 表示排序的二维距离的图表
k维的原始距离space.
这是一个示例,用于比较 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-03-11。