Determining the ideal number of clusters for clustering based on sequence (distance)

I wrote these functions for clustering data based on a sequence:

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")

However, here the number of clusters is arbitrarily assigned. Is there any way to show that the magnitude of the variance (or some similar measure) captured by a certain number of clusters begins to reach a point of decreasing returns in a certain number of clusters? I present something similar to the scree plot in factor analysis .

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

, . ( ): http://mephisto.unige.ch/weightedcluster/

+2

All Articles