Skip to contents

Validates a precomputed km_at_cl object (the output of KmeansInference::kmeans_inference()) against the data matrix X, the requested number of clusters NC and the pair of clusters to compare. Also discards km_at_cl when sample splitting is requested (since X changes after splitting), checks that clusters is a valid specification, and reconciles sample_split with return_X_clus.

Usage

validate_km_setting(km_at_cl, X, NC, clusters, sample_split, return_X_clus)

Arguments

km_at_cl

An optional precomputed output of KmeansInference::kmeans_inference(), or NULL.

X

A numeric \(n \times p\) data matrix.

NC

Integer scalar giving the number of clusters.

clusters

Integer vector of length 2 specifying the pair of clusters to compare. Entries must belong to 1:NC.

sample_split

Logical. Whether sample splitting is used to estimate Sigma.

return_X_clus

Logical. Whether the data matrix used for clustering should be returned.

Value

A named list with:

km_at_cl

The validated km_at_cl, or NULL if it was not provided or was discarded because sample_split = TRUE.

return_X_clus

The (possibly adjusted) return_X_clus flag.