Skip to main content
1 of 2
rdorlearn
  • 3.6k
  • 6
  • 29
  • 29

how to complement the results of cluster analysis with known groups

I have some prior knowledge of grouping, but this may be incorrect or is not sufficient as I need larger number of groups (i.e. subgroups). For example in the following data I have 3 groups in addition to two variables. I would like to use the group information (as prior knowledge) (here 3 groups) to create meaningful groups (here 9 groups/clusters). Is there a correct way to perform such analysis.

# Dummy data 
group <- rep(1:3, each =3000)
X <- c(rnorm(1000, 0.1, 0.04), rnorm(1000,0.2, 0.04), rnorm(1000, 0.3, 0.04),
       rnorm(1000, 0.4, 0.04), rnorm(1000,0.5, 0.04), rnorm(1000, 0.6, 0.04), 
       rnorm(1000, 0.7, 0.04), rnorm(1000,0.8, 0.04), rnorm(1000, 0.9, 0.04)
)

Y <-  c(rnorm(1000, 0.5, 0.04), rnorm(1000,0.6, 0.04), rnorm(1000, 0.7, 0.04),
       rnorm(1000, 0.35, 0.04), rnorm(1000,0.45, 0.04), rnorm(1000, 0.3, 0.04), 
       rnorm(1000, 0.55, 0.04), rnorm(1000,0.65, 0.04), rnorm(1000, 0.65, 0.04)
)

plot(X,Y, pch = ".")
cl <- kmeans(cbind(X,Y), 9)

colrs <- c("red","purple", "yellow", "tan", "pink", "cyan", "blue", "green", "black")
plot(cbind(X,Y), col = colrs[cl$cluster], pch = ".")
plot(cbind(X,Y), col = colrs[group], pch = ".")
rdorlearn
  • 3.6k
  • 6
  • 29
  • 29