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