Setup a PAMKConfig object for Partitioning Around Medoids with estimation
of the number of clusters (PAMK), via the 'fpc' package.
Usage
setup_PAMK(
krange = 2:10,
criterion = setup_ASWCriterion(),
use_pam = TRUE,
scaling = FALSE,
alpha = 0.001,
features = NULL
)Arguments
- krange
Integer [1, Inf) vector: Candidate numbers of clusters to compare. Must include at least one value greater than 1.
- criterion
PAMKCriterionConfig: Criterion used to choose the number of clusters, from setup_ASWCriterion, setup_CHCriterion or setup_MultiASWCriterion.- use_pam
Logical: If TRUE, fit each candidate with PAM; if FALSE, with CLARA.
- scaling
Logical: If TRUE, scale each variable by its root mean square after centering.
- alpha
Numeric [0, 1]: Significance level of the Duda-Hart test, used only when 1 is among the candidates.
- features
Optional Character vector: Names of at least 2 distinct feature columns to cluster on.
NULLclusters on all numeric features.
Details
PAMK fits PAM (or CLARA) for every candidate in krange and keeps the one
scoring best under criterion. There is therefore no k to set, and the
number of clusters chosen is reported by the resulting Clustering.
Argument names are rtemis' own. They map to fpc::pamk() as:
use_pam -> usepam; the criterion's type -> criterion and its
n_subsets -> ns; the rest keep their names.
fpc::pamk() also accepts a per-variable numeric vector for scaling; only
the logical form is exposed here. Scale by column with preprocess instead,
where the decision is recorded and replayed with the data.
References
Kaufman L, Rousseeuw PJ (1990). Finding Groups in Data: An Introduction to Cluster Analysis. Wiley. doi:10.1002/9780470316801
Examples
pamk_config <- setup_PAMK(krange = 2:5)
pamk_config#> <PAMK ClusteringConfig>
#> krange: <int> 2, 3, 4, 5
#> criterion:
#> <ASWCriterionConfig>
#>
#> type: <chr> asw
#> use_pam: <lgc> TRUE
#> scaling: <lgc> FALSE
#> alpha: <nmr> 1e-03setup_PAMK(krange = 2:5, criterion = setup_MultiASWCriterion(n_subsets = 20L))#> <PAMK ClusteringConfig>
#> krange: <int> 2, 3, 4, 5
#> criterion:
#> <MultiASWCriterionConfig>
#>
#> type: <chr> multiasw
#> n_subsets: <int> 20
#> use_pam: <lgc> TRUE
#> scaling: <lgc> FALSE
#> alpha: <nmr> 1e-03