Validates a precomputed hierarchical clustering object hcl and/or
distance object dismat against the data matrix X, infers or
validates the linkage criterion, and checks that clusters is a
valid specification. Also discards precomputed hcl and dismat
when sample splitting is requested (since X changes after
splitting), and reconciles sample_split with return_X_clus.
Usage
validate_hc_setting(
hcl,
dismat,
X,
NC,
clusters,
linkage,
linkage_missing,
sample_split,
return_X_clus
)Arguments
- hcl
An optional precomputed hierarchical clustering object of class
"hclust", as returned byfastcluster::hclust()orstats::hclust(), orNULL.- dismat
An optional precomputed squared Euclidean distance object of class
"dist", as returned bystats::dist(X, method = "euclidean")^2, orNULL.- X
An \(n \times p\) data matrix.
- NC
Integer. Number of clusters in the partition obtained by cutting the hierarchical clustering tree.
- clusters
Integer vector of length 2 containing the labels of the two clusters to compare. Entries must belong to
1:NC.- linkage
Character string specifying the linkage criterion used in hierarchical clustering. Ignored (and overridden) when
hclis provided.- linkage_missing
Logical. Whether
linkagewas left at its default (i.e.,missing(linkage)in the calling function), used to decide whether to warn about a mismatch withhcl$method.- 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:
- hcl
The validated
hcl, orNULLif it was not provided or was discarded becausesample_split = TRUE.- dismat
The validated
dismat, orNULLif it was not provided or was discarded becausesample_split = TRUE.- linkage
The validated (or
hcl-inferred) linkage criterion.- return_X_clus
The (possibly adjusted)
return_X_clusflag.
See also
Other Utilities:
ARI(),
is.CS(),
preserve.cl(),
setup.model(),
test_statistic(),
validate_km_candidate(),
validate_km_setting(),
validate_ndraws(),
validate_seed()