作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 R 执行层次聚类。作为第一种方法,我使用了 hclust
并执行了以下步骤:
as.dist
函数将其转换为 dist
对象dist
对象上运行 hclust
这是 R 代码:
distm <- read.csv("distMatrix.csv")
d <- as.dist(distm)
hclust(d, "ward")
此时我想用函数pvclust
做一些类似的事情;但是,我不能,因为不可能传递预先计算的 dist
对象。考虑到我使用的距离在 R 的 dist
函数提供的距离中不可用,我该如何继续?
最佳答案
我测试了文森特的建议,你可以这样做(我的数据集是相异矩阵):
# Import you data
distm <- read.csv("distMatrix.csv")
d <- as.dist(distm)
# Compute the eigenvalues
x <- cmdscale(d,1,eig=T)
# Plot the eigenvalues and choose the correct number of dimensions (eigenvalues close to 0)
plot(x$eig,
type="h", lwd=5, las=1,
xlab="Number of dimensions",
ylab="Eigenvalues")
# Recover the coordinates that give the same distance matrix with the correct number of dimensions
x <- cmdscale(d,nb_dimensions)
# As mentioned by Stéphane, pvclust() clusters columns
pvclust(t(x))
关于r - 将 pvclust R 函数应用于预先计算的 dist 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8924488/
在R的pvclust包中,有pvclust()函数。在函数帮助文件中提供的示例中,有以下函数: boston.pp <- pvpick(boston.pv) 这应该打印出具有高 p 值的簇。该函数的输
我正在运行一些聚类分析,我试图弄清楚两个主要的事情: 1)如何最好地解释 pvclust 中 p 值的结果(他们正在建立的空值是什么?) 2)如何将这些结果翻译成hclust 我将使用 mtcars以
我正在使用 R 执行层次聚类。作为第一种方法,我使用了 hclust 并执行了以下步骤: 我导入了距离矩阵 我使用 as.dist 函数将其转换为 dist 对象 我在 dist 对象上运行 hclu
pvclust 非常适合在 R 中进行聚类分析。但是,当它作为批处理操作的一部分运行时,对于相同的数据得到不同的结果是很烦人的。显然,同一数据有许多“正确”的聚类,似乎 pvclust 使用了一些随机
我是一名优秀的程序员,十分优秀!