Table of Contents
Section: Numerical classification
Cluster analysis (hierarchical agglomerative classification)
R functions
hclust- calculates hierarchical cluster analysis (part of standardstatslibrary). Requires at least two arguments:dfor distance matrix, andmethodfor agglomerative algorithm, one ofward.D,ward.D2,single,complete,average(= UPGMA),mcquitty(= WPGMA),median(= WPGMC) orcentroid(= UPGMC). It has its ownplotfunction (stats:::plot.hclust).rect.hclust- divides dendrogram into given number of groups (argumentk) and draws rectangles around samples in these groups (argumentborderspecifies the color of the rectangle).cutree- cuts the tree (dendrogram) into a given number of clusters (argumentk) or according to a given level of similarity (argumenth). Returns a vector with the assignment of samples into groups.agnes(library cluster) - contains six agglomerative algorithms, some not included inhclust. It has its ownplotmethod (cluster:::plot.agnes).- library (dendextend) - contains several functions improving representation of the dendrogram (e.g., plotting dendrogram with branches of different colour)
Note about Ward's hierarchical clustering algorithm
Murtagh & Legendre (2014) have shown that what literature refers to as Ward's clustering algorithm are in fact two slightly different methods, while only one of them is identical with the algorithm originally described by Ward. Both functions hclust and agnes have the method = 'ward', but with different defaults. While the hclust function implements both Ward's algorithms (the genuine one, named ward.D2, as well as the second one, called ward.D), the agnes function implements only the genuine one. For historical reasons, the argument method = 'ward' '' in ''hclust invokes the ward.D algorithm rather than the ward.D2 algorithm. This means that hclust and agnes function, if both are set to method = 'ward' '', return slightly different results. To calculate “genuine” Ward's algorithm in both methods, you need to set up ''method = 'ward.D2' '' in ''hclust, and method = 'ward' '' in ''agnes.
