Skip to content
Back to formatted view

Raw Message

Message-ID: <D52F84A2AE107848949A8C7E45F02D699DEA5E@MAIL.fc.up.pt>
Date: 2003-06-06T10:15:48Z
From: Luis Silva
Subject: Kmeans again

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:
 
> dados<-matrix(c(-1,0,2,2.5,7,9,0,3,0,6,1,4),6,2)

I will choose observations 3 and 4 for initial centers and just one iteration. The results are
 
> A<-kmeans(dados,dados[c(3,4),],1)
> A
$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.