| BestC | R Documentation |
This function determines the best number of clusters (C) for longitudinal data clustering based on internal validation indices using the latrend package.
BestC(Y, range_clusters = 2:6, method = "kml")
Y |
A matrix or data frame of longitudinal outcomes (subjects x timepoints). |
range_clusters |
A numeric vector of cluster numbers to evaluate (e.g., 2:6). |
method |
Clustering method to use. Currently supports "kml" (default). |
A list with:
best_c |
Optimal number of clusters |
criteria |
Data frame of criteria values for each cluster number |
criteria_best |
Criteria values for the best cluster number |
set.seed(123)
n <- 30
T <- 3
y <- matrix(rnorm(n * T), nrow = n)
best_c_info <- BestC(Y = y, range_clusters = 2:4)
print(best_c_info$best_c)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.