Evaluates the stability of cluster assignments for a SINGLE selected model using bootstrap resampling. For each bootstrap sample, the clustering is re-run with the same model specification and assignments are compared to the original using the Adjusted Rand Index.
Note: This function assesses one model at a time. If you tested multiple models, use the model_name parameter to specify which model to assess, or leave NULL to use the best model by BIC.
Usage
assess_cluster_stability(
results,
model_name = NULL,
n_boot = 100,
verbose = TRUE,
seed = NULL
)Value
A list of class "cluster_stability" containing:
overall_stability: Mean Adjusted Rand Index across bootstrapsstability_sd: Standard deviation of ARIbootstrap_ari: Vector of ARI values for each bootstrapobservation_stability: Proportion of times each observation was assigned to the same cluster as in the originalcluster_stability: Stability score for each clusterinterpretation: Text interpretation of stability
Examples
if (FALSE) { # \dontrun{
results <- clustering(data, vars, n_clusters = 3)
# Assess stability of best model (default)
stability <- assess_cluster_stability(results, n_boot = 100)
# Assess a specific model
stability <- assess_cluster_stability(results, model_name = "VVV", n_boot = 50)
# View results
print(stability)
stability$overall_stability
stability$interpretation
# Plot observation stability
hist(stability$observation_stability, main = "Observation Stability")
} # }