Learn R Programming

fdm2id (version 1.0.1)

PAM: Clustering using K-medoids (PAM)

Description

Partitions the data into k clusters around medoids -- actual observations of the dataset -- rather than around means. Being an observation, a medoid can be shown to students as a representative example of its cluster, and the method tolerates outliers much better than K-means, which drags a mean towards them.

Usage

PAM(
  d,
  k = 9,
  criterion = c("none", "silhouette"),
  graph = FALSE,
  seed = NULL,
  ...
)

Value

The clustering, as an object of class pam (see pam), with a cluster component holding the assignments and a medoids one holding the representative observations.

Arguments

d

The dataset (matrix or data.frame).

k

The number of clusters.

criterion

How k is chosen, as in KMEANS. With "none" (the default) k is used as it is; with "silhouette" it is chosen between 2 and k by the mean silhouette width, the criterion PAM itself optimises the closest.

graph

A logical indicating whether the criterion curve is plotted.

seed

A specified seed for random number generation. PAM's initialisation is deterministic, so this only matters for the criterion search.

...

Other parameters, passed to pam.

See Also

KMEANS, pam, kmeans.getk

Examples

Run this code
require (datasets)
data (iris)
model = PAM (iris [, -5], 3)
model$medoids
table (model$cluster, iris [, 5])

Run the code above in your browser using DataLab