% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/BestC.R
\name{BestC}
\alias{BestC}
\title{Find Optimal Number of Clusters for Longitudinal Data}
\usage{
BestC(Y, range_clusters = 2:6, method = "kml")
}
\arguments{
\item{Y}{A matrix or data frame of longitudinal outcomes (subjects x timepoints).}

\item{range_clusters}{A numeric vector of cluster numbers to evaluate (e.g., 2:6).}

\item{method}{Clustering method to use. Currently supports "kml" (default).}
}
\value{
A list with:
\item{best_c}{Optimal number of clusters}
\item{criteria}{Data frame of criteria values for each cluster number}
\item{criteria_best}{Criteria values for the best cluster number}
}
\description{
This function determines the best number of clusters (C) for longitudinal data
clustering based on internal validation indices using the latrend package.
}
\examples{
\donttest{
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)
}

}
