## generate 25 objects, divided into 2 clusters.
x <- rbind(cbind(rnorm(10,0,0.5), rnorm(10,0,0.5)),
cbind(rnorm(15,5,0.5), rnorm(15,5,0.5)))
pamx <- pam(x, 2)
pamx
summary(pamx)
plot(pamx)
## use obs. 1 & 16 as starting medoids -- same result (typically)
(p2m <- pam(x, 2, medoids = c(1,16)))
p3m <- pam(x, 3, trace = 2)
## rather stupid initial medoids:
(p3m. <- pam(x, 3, medoids = 3:1, trace = 1))
ii <- pmatch(c("obj","call"), names(pamx))
stopifnot(all.equal(pamx[-ii], p2m[-ii], tol=1e-14),
all.equal(pamx[["obj"]][2], p2m[["obj"]][2], tol=1e-14))
pam(daisy(x, metric = "manhattan"), 2, diss = TRUE)
data(ruspini)
## Plot similar to Figure 4 in Stryuf et al (1996)
plot(pam(ruspini, 4), ask = TRUE)
plot(pam(ruspini, 4))
Run the code above in your browser using DataLab