library(UniversalCVI)
# The data is from Wiroonsri (2024).
x = R1_data[,1:2]
# ---- FCM algorithm ----
# Compute all the indices by WP.IDX using default gamma
FCM.WP = WP.IDX(scale(x), cmax = 10, cmin = 2, corr = 'pearson', method = 'FCM', fzm = 2,
iter = 100, nstart = 20, NCstart = TRUE)
print(FCM.WP$WP)
# The optimal number of cluster
FCM.WP$WP[which.max(FCM.WP$WP$WPI),]
# ---- EM algorithm ----
# Compute all the indices by WP.IDX using default gamma
EM.WP = WP.IDX(scale(x), cmax = 10, cmin = 2, corr = 'pearson', method = 'EM',
iter = 100, nstart = 20, NCstart = TRUE)
print(EM.WP$WP)
# The optimal number of cluster
EM.WP$WP[which.max(EM.WP$WP$WPI),]
Run the code above in your browser using DataLab