Sunday, March 3, 2013

Hierarchical Clustering in R

rm(list=ls())
#install.packages("ElemStatLearn")
library(ElemStatLearn)
data(nci)
# DNA Expression Microarrays
# from the book "The Elements of Statistical Learning"
# Algorithm described in page 520 -- page 528
head(nci)

# complete linakge
com.hclust = hclust(dist(t(nci)),method="complete")
plot(com.hclust,cex=.7, xlab="")




# single linakge
sing.hclust = hclust(dist(t(nci)),method="single")
plot(sing.hclust,cex=.7, xlab="")



# average linakge
ave.hclust = hclust(dist(t(nci)),method="average")
plot(ave.hclust,cex=.7, xlab="")


# average linakge - maximum distance
ave.hclust = hclust(dist(t(nci),method="maximum"),method="average")
plot(ave.hclust,cex=.7, xlab="")

No comments:

Post a Comment