Skip to contents

Setup a PAMConfig object for Partitioning Around Medoids (PAM) clustering, via the 'cluster' package.

Usage

setup_PAM(
  k = 3L,
  dist = "euclidean",
  stand = FALSE,
  do_swap = TRUE,
  variant = "original",
  nstart = NULL,
  features = NULL
)

Arguments

k

Integer [1, Inf): Number of clusters. Must be fewer than the number of cases.

dist

Character {"euclidean", "manhattan"}: Distance measure to use.

stand

Logical: If TRUE, standardize each variable before computing dissimilarities.

do_swap

Logical: If TRUE, perform the swap phase.

variant

Character {"original", "o_1", "o_2", "f_3", "f_4", "f_5", "faster"}: Algorithm variant; "original" is the published algorithm, the others trade exactness for speed.

nstart

Optional Integer [1, Inf): Number of random starts. NULL uses the deterministic build phase instead of drawing the initial medoids at random.

features

Optional Character vector: Names of at least 2 distinct feature columns to cluster on. NULL clusters on all numeric features.

Value

PAMConfig object.

Details

PAM is the medoid-based counterpart of k-means: each cluster is represented by one of the cases, which makes it usable with non-Euclidean dissimilarities and less sensitive to outliers.

Argument names are rtemis' own. They map to cluster::pam() as: dist -> metric, do_swap -> do.swap; the rest keep their names.

References

Kaufman L, Rousseeuw PJ (1990). Finding Groups in Data: An Introduction to Cluster Analysis. Wiley. doi:10.1002/9780470316801

Author

EDG

Examples

pam_config <- setup_PAM(k = 3L)
pam_config
#> <PAM ClusteringConfig>
#>       k: <int> 3
#>    dist: <chr> euclidean
#>   stand: <lgc> FALSE
#> do_swap: <lgc> TRUE
#> variant: <chr> original
#>  nstart: <NUL> NULL