Homogeneity analysis of hierarchical classifications

I've spent more years than I care to remember analysing vegetation survey data (typically species abundances in plots) using a variety of software including my own algorithms coded in FORTRAN and C++. A recent query on the r-help list, about how to determine the number of groups to define in a hierarchical classification produced with the hclust function, prompted me to unearth one of these algorithms, homogeneity analysis1, which can help to visualize how different levels of grouping partition the variability in a distance matrix.This algorithm is extremely simple. The classification is progressively divided into groups, with all groups being defined at the same dendrogram height. At each level of grouping, the average of within-group pairwise distances is calculated. Homogeneity is then defined as:

H = 1 - Davwithin-group - Davtotal

where Davtotal is the average pairwise distance in the dataset as a whole.

For data were there exist well-defined clusters of values, a plot of homogeneity against number of groups will display an 'elbow' where the initial rapid increase in homogeneity turns to a more gradual increase. The example above shows a classification of the USArrests dataset and corresponding homogeneity plot which suggests defining 7 groups. It was generated as follows:

# R version of homogeneity analysis as described in:# Bedward, Pressey and Keith. 1992. Homogeneity analysis: assessing the # utility of classifications and maps of natural resources# Australian Journal of Ecology 17:133-139.## Arguments:# d - either an object produced by dist() or a vector of# pairwise dissimilarity values ordered in the manner of# a dist result## hc - classification produced by hclust()## Value:# A two column matrix of number of groups and corresponding homogeneity value## This code by Michael Bedward, 2010