library(UniversalCVI)
# The data is from Wiroonsri (2024).
x = R1_data[,1:2]
# ---- Kmeans ----
# Compute the CH index
K.CH = CH.IDX(scale(x), kmax = 15, kmin = 2, method = "kmeans", nstart = 100)
print(K.CH)
# The optimal number of cluster
K.CH[which.max(K.CH$CH),]
# ---- Hierarchical ----
# Average linkage
# Compute the CH index
H.CH = CH.IDX(scale(x), kmax = 15, kmin = 2, method = "hclust_average")
print(H.CH)
# The optimal number of cluster
H.CH[which.max(H.CH$CH),]
Run the code above in your browser using DataLab