Skip to contents

This function computes clustering evaluation measures for functional data objects of class 'fdata'. It supports the calculation of the Dunn, Davies-Bouldin, Calinski-Harabasz, and Silhouette indices. Distances are computed using the metric.lp function from the fda.usc package by default, but users can specify a different distance metric via the 'metric' parameter. Cluster means are calculated using an appropriate function, which can be specified by the user via the 'center_func' argument.

Usage

fclust.measures(
  X,
  clusters,
  index = "silhouette",
  metric = metric.lp,
  par.metric = list(),
  center_func = func.mean
)

Arguments

X

An fdata object containing the functional data. The rows represent observations and the columns represent discrete evaluations of the functional data.

clusters

A vector containing the cluster assignments for each observation in the fdata object.

index

A character string indicating the measure to compute. Possible options are "silhouette" (default), "dunn", "db" (Davies-Bouldin), or "ch" (Calinski-Harabasz).

metric

A function specifying the distance metric to be used. The default is 'metric.lp'.

par.metric

A list of parameters to be passed to the 'metric' function.

center_func

A function to compute cluster means, with possible options like 'func.mean', 'func.trim.mode', or other user-defined functions.

Value

The value of the selected clustering measure.

Examples

set.seed(123)
t <- seq(0, 2 * pi, length.out = 101)
res <- rprocKclust(t, n = c(30, 50, 40), 
                   process = c("cos_sin", "sin", "cos"), 
                   c = c(-1, 1, 1), k = c(NA, NA, NA), 
                   s = c(0.2, 0.3, 0.1))
X <- res$X
clusters <- res$groups
silhouette_val <- fclust.measures(X, clusters, index = "silhouette")
dunn_val <- fclust.measures(X, clusters, index = "dunn")
db_val <- fclust.measures(X, clusters, index = "db")
ch_val <- fclust.measures(X, clusters, index = "ch")
print(silhouette_val)
#> [1] 0.407778
print(dunn_val)
#> [1] 0.8951075
print(db_val)
#> [1] 1.507773
print(ch_val)
#> [1] 118.2537