kmeansruns {fpc} | R Documentation |
k-means with estimating k and initialisations
Description
This calls the function kmeans
to perform a k-means
clustering, but initializes the k-means algorithm several times with
random points from the data set as means. Furthermore, it is more
robust against the occurrence of empty clusters in the algorithm and
it estimates the number of clusters by either the Calinski Harabasz
index (calinhara
) or average silhouette width (see
pam.object
). 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).
Usage
kmeansruns(data,krange=2:10,criterion="ch",
iter.max=100,runs=100,
scaledata=FALSE,alpha=0.001,
critout=FALSE,plot=FALSE,...)
Arguments
data |
A numeric matrix of data, or an object that can be coerced to such a matrix (such as a numeric vector or a data frame with all numeric columns). |
krange |
integer vector. Numbers of clusters which are to be
compared by the average silhouette width criterion. Note: average
silhouette width and Calinski-Harabasz can't estimate number of
clusters |
criterion |
one of |
iter.max |
integer. The maximum number of iterations allowed. |
runs |
integer. Number of starts of the k-means algorithm. |
scaledata |
logical. If |
alpha |
numeric between 0 and 1, tuning constant for
|
critout |
logical. If |
plot |
logical. If |
... |
further arguments to be passed on to |
Value
The output of the optimal run of the kmeans
-function
with added components bestk
and crit
.
A list with components
cluster |
A vector of integers indicating the cluster to which each point is allocated. |
centers |
A matrix of cluster centers. |
withinss |
The within-cluster sum of squares for each cluster. |
size |
The number of points in each cluster. |
bestk |
The optimal number of clusters. |
crit |
Vector with values of the |
Author(s)
Christian Hennig christian.hennig@unibo.it https://www.unibo.it/sitoweb/christian.hennig/en/
References
Calinski, T., and Harabasz, J. (1974) A Dendrite Method for Cluster Analysis, Communications in Statistics, 3, 1-27.
Duda, R. O. and Hart, P. E. (1973) Pattern Classification and Scene Analysis. Wiley, New York.
Hartigan, J. A. and Wong, M. A. (1979). A K-means clustering algorithm. Applied Statistics, 28, 100-108.
Kaufman, L. and Rousseeuw, P.J. (1990). "Finding Groups in Data: An Introduction to Cluster Analysis". Wiley, New York.
See Also
kmeans
, pamk
,
calinhara
, dudahart2
)
Examples
options(digits=3)
set.seed(20000)
face <- rFace(50,dMoNo=2,dNoEy=0,p=2)
pka <- kmeansruns(face,krange=1:5,critout=TRUE,runs=2,criterion="asw")
pkc <- kmeansruns(face,krange=1:5,critout=TRUE,runs=2,criterion="ch")