The R Project SVN R

Rev

Rev 86303 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 86303 Rev 88563
Line 1... Line 1...
1
% File src/library/stats/man/kmeans.Rd
1
% File src/library/stats/man/kmeans.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2023 R Core Team
3
% Copyright 1995-2025 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{kmeans}
6
\name{kmeans}
7
\alias{kmeans}
7
\alias{kmeans}
8
\alias{print.kmeans}
8
\alias{print.kmeans}
Line 49... Line 49...
49
  which aims to partition the points into \eqn{k} groups such that the
49
  which aims to partition the points into \eqn{k} groups such that the
50
  sum of squares from points to the assigned cluster centres is minimized.
50
  sum of squares from points to the assigned cluster centres is minimized.
51
  At the minimum, all cluster centres are at the mean of their \I{Voronoi}
51
  At the minimum, all cluster centres are at the mean of their \I{Voronoi}
52
  sets (the set of data points which are nearest to the cluster centre).
52
  sets (the set of data points which are nearest to the cluster centre).
53
 
53
 
54
  The algorithm of \bibcite{Hartigan and Wong (1979)} is used by
54
  The algorithm of \bibcitet{R:Hartigan+Wong:1979} is used by
55
  default.  Note that some authors use \eqn{k}-means to refer to a
55
  default.  Note that some authors use \eqn{k}-means to refer to a
56
  specific algorithm rather than the general method: most commonly the
56
  specific algorithm rather than the general method: most commonly the
57
  algorithm given by \bibcite{MacQueen (1967)} but sometimes that given
57
  algorithm given by \bibcitet{R:MacQueen:1967} but sometimes that given
58
  by \bibcite{Lloyd (1957)} and \bibcite{Forgy (1965)}.
58
  by \bibcitet{R:Lloyd:1957, R:Lloyd:1982} and \bibcitet{R:Forgy:1965}.
59
  The \I{Hartigan}--\I{Wong} algorithm generally does a better job than
59
  The \I{Hartigan}--\I{Wong} algorithm generally does a better job than
60
  either of those, but trying several random starts (\code{nstart}\eqn{>
60
  either of those, but trying several random starts (\code{nstart}\eqn{>
61
  1}) is often recommended.  In rare cases, when some of the points
61
  1}) is often recommended.  In rare cases, when some of the points
62
  (rows of \code{x}) are extremely close, the algorithm may not converge
62
  (rows of \code{x}) are extremely close, the algorithm may not converge
63
  in the \dQuote{Quick-Transfer} stage, signalling a warning (and
63
  in the \dQuote{Quick-Transfer} stage, signalling a warning (and
Line 98... Line 98...
98
  \item{iter}{The number of (outer) iterations.}
98
  \item{iter}{The number of (outer) iterations.}
99
  \item{ifault}{integer: indicator of a possible algorithm problem
99
  \item{ifault}{integer: indicator of a possible algorithm problem
100
    -- for experts.}
100
    -- for experts.}
101
}
101
}
102
\references{
102
\references{
103
  Forgy, E. W. (1965).
-
 
104
  Cluster analysis of multivariate data: efficiency vs interpretability
-
 
105
  of classifications. 
-
 
106
  \emph{Biometrics}, \bold{21}, 768--769.
-
 
107
 
-
 
108
  Hartigan, J. A. and Wong, M. A. (1979).
-
 
109
  Algorithm AS 136: A K-means clustering algorithm.
-
 
110
  \emph{Applied Statistics}, \bold{28}, 100--108.
-
 
111
  \doi{10.2307/2346830}.
-
 
112
 
-
 
113
  Lloyd, S. P. (1957, 1982).
-
 
114
  Least squares quantization in PCM.
-
 
115
  Technical Note, Bell Laboratories.
-
 
116
  Published in 1982 in \emph{IEEE Transactions on Information Theory},
-
 
117
  \bold{28}, 128--137. 
-
 
118
 
-
 
119
  MacQueen, J. (1967).
-
 
120
  Some methods for classification and analysis of multivariate
-
 
121
  observations.
103
  \bibshow{*}
122
  In \emph{Proceedings of the Fifth Berkeley Symposium on  Mathematical
-
 
123
    Statistics and Probability}, 
-
 
124
  eds L. M. Le Cam & J. Neyman,
-
 
125
  \bold{1}, pp.\sspace{}281--297.
-
 
126
  Berkeley, CA: University of California Press.
-
 
127
}
104
}
128
\examples{
105
\examples{
129
require(graphics)
106
require(graphics)
130
 
107
 
131
# a 2-dimensional example
108
# a 2-dimensional example