pam or
clara to perform a
partitioning around medoids clustering with the number of clusters
estimated by optimum average silhouette width (see
pam.object) or Calinski-Harabasz
index (calinhara). The Duda-Hart test
(dudahart2) is applied to decide whether there should be
more than one cluster (unless 1 is excluded as number of clusters).pamk(data,krange=2:10,criterion="asw", usepam=TRUE,
scaling=FALSE, alpha=0.001, diss=inherits(data, "dist"),
critout=FALSE, ...)pam for more information.nc=1. If 1 is included, a Duda-Hart tes"asw" or "ch". Determines
whether average silhouette width or Calinski-Harabasz is applied.scaling is a numeric
vector with length equal to the number of variables, then each
variable is divided by the corresponding value from dudahart2 (only used for 1-cluster test).TRUE (default for dist or
dissimilarity-objects), then data will be considered
as a dissimilarity matrix. If FALSE, then data will
be considered asTRUE, the criterion value is printed
out for every number of clusters.pam-function.Duda, R. O. and Hart, P. E. (1973) Pattern Classification and Scene Analysis. Wiley, New York.
Kaufman, L. and Rousseeuw, P.J. (1990). "Finding Groups in Data: An Introduction to Cluster Analysis". Wiley, New York.
pam, claraset.seed(20000)
face <- rFace(50,dMoNo=2,dNoEy=0,p=2)
pk <- pamk(face,krange=1:5,criterion="asw",critout=TRUE)
pk <- pamk(face,krange=1:5,criterion="ch",critout=TRUE)Run the code above in your browser using DataLab