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