15.5 Evaluation of Cluster Validity

# Fig. 15.8.: PAM validity
library(StatDA)
data(chorizon)

el=c("Na","Ca","K","Al")
x=chorizon[,el]
sel=((chorizon[,"LITO"]==9) | (chorizon[,"LITO"]==82))
x=scale(log10(x[sel,]))
lab=chorizon[sel,"LITO"]
lab.new=lab
lab.new[lab==82] <- 1
lab.new[lab==9] <- 3
set.seed(100)
res2=pam(x,2,metric="manhattan")
set.seed(100)
res3=pam(x,3,metric="manhattan")

pdf("fig-15-8.pdf",width=9,height=6)
par(mfrow=c(1,2),mar=c(5,4,2,3))

plot(res2, which.plots=2,main="")
plot(res3, which.plots=2,main="")

dev.off()