clustMixType (version 0.2-2)

gplus_kproto: Validating k Prototypes Clustering: Gplus index

Description

Calculating the Gplus index for a k-Prototypes clustering with k clusters or computing the optimal number of clusters based on the Gplus index for k-Prototype clustering.

Usage

gplus_kproto(object = NULL, data = NULL, k = NULL, dists = NULL,
  ...)

Arguments

object

Object of class kproto resulting from a call with kproto(..., keep.data=TRUE)

data

Original data; only required if object == NULL.

k

Vector specifying the search range for optimum number of clusters; if NULL the range will set as 2:sqrt(n). Only required if object == NULL.

dists

for internal purposes only

...

Further arguments passed to kproto, like:

  • nstart: If > 1 repetetive computations of kproto with random initializations are computed.

  • lambda: Factor to trade off between Euclidean distance of numeric variables and simple matching coefficient between categorical variables.

  • verbose: Logical whether information about the cluster procedure should be given. Caution: If verbose=FALSE, the reduction of the number of clusters is not mentioned.

Value

For computing the optimal number of clusters based on the Gplus index for k-Prototype clustering the output contains:

k_opt

optimal number of clusters

indices

calculated indices for \(k=2,...,k_{max}\)

For computing the Gplus index-value for a given k-Prototype clustering the output contains:

index

calculated index-value

Details

$$Gplus = \frac{2 \cdot s(-)}{\frac{n(n-1)}{2} \cdot (\frac{n(n-1)}{2}-1)}$$ Comparisons are made between all within-cluster dissimilarities and all between-cluster dissimilarities. \(s(-)\) is the number of discordant comparisons and a comparison is named discordant if a within-cluster dissimilarity is strictly greater than a between-cluster dissimilarity. The minimum value of the index is used to indicate the optimal number of clusters.

References

See Also

Other clustervalidation indices: dunn_kproto, dunn_kproto, gamma_kproto, mcclain_kproto, ptbiserial_kproto, silhouette_kproto, tau_kproto

Examples

Run this code
# NOT RUN {
# generate toy data with factors and numerics

n   <- 10
prb <- 0.99
muk <- 2.5

x1 <- sample(c("A","B"), 2*n, replace = TRUE, prob = c(prb, 1-prb))
x1 <- c(x1, sample(c("A","B"), 2*n, replace = TRUE, prob = c(1-prb, prb)))
x1 <- as.factor(x1)

x2 <- sample(c("A","B"), 2*n, replace = TRUE, prob = c(prb, 1-prb))
x2 <- c(x2, sample(c("A","B"), 2*n, replace = TRUE, prob = c(1-prb, prb)))
x2 <- as.factor(x2)

x3 <- c(rnorm(n, mean = -muk), rnorm(n, mean = muk), rnorm(n, mean = -muk), rnorm(n, mean = muk))
x4 <- c(rnorm(n, mean = -muk), rnorm(n, mean = muk), rnorm(n, mean = -muk), rnorm(n, mean = muk))

x <- data.frame(x1,x2,x3,x4)

# apply k prototyps
kpres <- kproto(x, 4, keep.data=TRUE)

# calculate index-value
gplus_value <- gplus_kproto(object = kpres)

# calculate optimal number of cluster
k_opt <- gplus_kproto(data = x, k = 3:5, nstart = 5, verbose = FALSE)

# }

Run the code above in your browser using DataLab