[R] k-means / role of 'nstart'

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Dec 2 12:43:36 CET 2005

On Fri, 2 Dec 2005, Charles Raux wrote:

> the k-means {stats} help and the Hartigan&Won paper say nothing about
> the way random sets works (parameter nstart). I would expect to get
> the different results for each random initial set but I always obtain
> only one result: how is it selected?

The code works as documented.  It tries 'nstart' random starts, 
but reports (as it says)

      The data given by 'x' is clustered by the k-means method, which
      aims to partition the points into k groups such that the sum of
      squares from points to the assigned cluster centres is minimized.

that is the clustering with the smallest value of the criterion.

You could just read the code for the details.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list