Pregunta

He escrito estas funciones para agrupar datos basados en secuencias:

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

Sin embargo, aquí el número de grupos está asignado arbitrariamente.¿Hay alguna forma de poder mostrar que la cantidad de varianza (o alguna medida similar) capturada por un cierto número de grupos comienza a alcanzar un punto de rendimientos decrecientes en un cierto número de clusters?Estoy imaginando algo similar a una complot Scree enanálisis factorial .

¿Fue útil?

Solución

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

Esto dará múltiples índices para encontrar el número ideal de grupos, así como como gráfico.Puede encontrar más información sobre los índices aquí (bajo calidad de clúster): http://mephisto.unige.ch/weightedcluster/

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top