Select the Number of Clusters by Split/Merge Search
Source:R/SelectionNClusters.R
SelectionNClusters.RdR6 class for selecting the number of clusters (q) by forward/backward split-and-merge exploration, comparing models with the ICL.
Kept internal/unexported for reference: empirically (see [NormalBlockVarCollectionClusters]'s `refine()` documentation) chaining every q from a single starting point this way is no longer recommended over [NormalBlockVarCollectionClusters]'s independent per-q cold starts followed by `refine()` – the latter matches or beats this class's quality at a fraction of the cost on every real dataset tested, and has no equivalent to this class's failure mode (an early bad split/merge propagating to every larger q it explores from there).
Public fields
best_modelslist of models explored so far indexed by the cluster sizes
ICL_exploredlist of ICL reached so far, indexed by the cluster sizes
n_clusters_rangethe range of the cluster sizes to browse
controlstore the list of user-defined model settings and optimization parameters
Methods
SelectionNClusters$new()
Explores and selects the optimal number of classes
Usage
SelectionNClusters$new(
mydata,
n_clusters_range,
zero_inflation = FALSE,
sparsity = 0,
control = NB_control()
)Arguments
mydataobject of NormalBlockData class, with responses and design matrix
n_clusters_rangea size-2 vector with the range of cluster size to browse
zero_inflationwhether the models in the collection should be zero-inflated or not
sparsitysparsity penalty on the network density
controlstructured list of more specific parameters, to generate with NB_control
SelectionNClusters$fit()
perform model selection with forward/backward exploration with split and merge strategy
SelectionNClusters$train_best_candidates()
perform model selection with forward/backward exploration with split and merge strategy
SelectionNClusters$plot()
Display the ICL for all the best models explored per number of cluster, and the winner