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.4, 0.02),
rnorm(1000, 0.4, 0.04), rnorm(1000,0.5, 0.08), rnorm(1000, 0.6, 0.12),
rnorm(1000, 0.7, 0.08), rnorm(1000,0.8, 0.1), rnorm(1000, 0.9, 0.06)
)
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.12), rnorm(1000,0.45, 0.04), rnorm(1000, 0.3, 0.02),
rnorm(1000, 0.55, 0.09), rnorm(1000,0.65, 0.12), rnorm(1000, 0.65, 0.04)
)
Prior information of 3 clusters:
col = c("red", "cyan", "green")
plot(cbind(X,Y), col = col[group], pch = ".")
Clustering analysis assuming 9 clusters.
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 = ".")