Skip to content

Kmeans again

2 messages · Luis Silva, Douglas Grove

#
Dear helpers
 
I'm sorry to insist but I still think there is something wrong with the function kmeans. For instance, let's try the same small example:
I will choose observations 3 and 4 for initial centers and just one iteration. The results are
$cluster
[1] 1 1 1 1 2 2
$centers
   [,1] [,2]
1 0.875 2.75
2 8.000 2.50
$withinss
[1] 38.9375  6.5000
$size
[1] 4 2
 
If I do it by hand, after one iteration, the results are
 
$cluster
[1] 1 2 1 2 1 2
 
So I think that something is wrong with the function kmeans; probably the initial centers given by the user are not being taken into account.
#
Andy Liaw already gave an example where he specified two different starting 
values and Kmeans gave different results after 1 iteration, so clearly 
your hypothesis is incorrect.

Either your calculations are wrong or you are calculating the wrong
formulae.  It is very doubtful that anything is wrong with Kmeans.

Doug Grove