确定基于序列(距离)的聚类的理想簇数

时间:2014-02-26 15:50:09

标签: r cluster-analysis traminer sequence-alignment

我已经编写了这些函数来聚类基于序列的数据:

library(TraMineR)
library(cluster)

clustering <- function(data){
  data <- seqdef(data, left = "DEL", gaps = "DEL", right = "DEL")
  couts <- seqsubm(data, method = "CONSTANT")
  data.om <- seqdist(data, method = "OM", indel = 3, sm = couts)
  clusterward <- agnes(data.om, diss = TRUE, method = "ward")
  (clusterward)
}

rc <- clustering(rubinius_sequences)

cluster_cut <- function(data, clusterward, n_clusters, name_clusters){
  data <- seqdef(data, left = "DEL", gaps = "DEL", right = "DEL")
  cluster4 <- cutree(clusterward, k = n_clusters)
  cluster4 <- factor(cluster4, labels = c("Type 1", "Type 2", "Type 3", "Type 4"))
  (data[cluster4==name_clusters,])
}

rc1 <- cluster_cut(project_sequences, rc, 4, "Type 1")

然而,这里任意分配簇的数量。有没有什么方法可以证明一定数量的聚类所捕获的方差(或一些类似的度量)开始达到一定数量聚类的收益递减点?我在想象类似于scree plot in factor analysis的东西。

1 个答案:

答案 0 :(得分:2)

library(WeightedCluster)  
(agnesRange <- wcKMedRange(rubinius.dist, 2:10))
plot(agnesRange, stat = c("ASW", "HG", "PBC"), lwd = 5)

这将给出多个索引,用于查找理想的聚类数量以及图表。有关索引的更多信息可以在此处找到(在群集质量下): http://mephisto.unige.ch/weightedcluster/

相关问题