Hello all.
I wish to run k-means with "manhattan" distance.
Since this is not supported by the function "kmeans", I turned to the "pam"
function in the "fpc" package.
Yet, when I tried to have the algorithm run with different starting points,
I found that pam ignores and keep on starting the algorithm from the same
starting-points (medoids).
For my questions:
1) is there a bug in the code or in the way I am using it ?
2) is there a way to either fix the code or to another function in some
package that can run kmeans with manhattan distance (manhattan distances are
the sum of absolute differences) ?
here is a sample code:
require(fpc)
x <- rbind(cbind(rnorm(10,0,0.5), rnorm(10,0,0.5)),
cbind(rnorm(15,5,0.5), rnorm(15,5,0.5)))
pam(x, 2, medoids = c(1,16))
output:
Medoids:
ID
[1,] 3 -0.1406026 0.1131493
[2,] 17 4.9564839 4.6480520
...
So the initial medeoids where 3 and 17, not 1 and 16 as I asked.
Thanks,
Tal
--
----------------------------------------------
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
www.talgalili.com
www.biostatistics.co.il
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.