Learn R Programming

lmomRFA (version 3.8)

cluagg: Hierarchical clustering

Description

Performs cluster analysis by one of several agglomerative hierarchical methods.

Usage

cluagg(x, method="ward")

Value

A list with elements as follows.

merge

Matrix of dimension (nrow(x)-1,2). The \(i\)th row contains the labels of the clusters merged at the \(i\)th merge.

wgss

Vector of length nrow(x)-1. The \(i\)th element is the total within-cluster dispersion after the \(i\)th merge.

Arguments

x

A numeric matrix (or a data frame with all numeric columns, which will be coerced to a matrix). Contains the data: each row should contain the attributes for a single point.

method

Clustering method. Any method valid for hclust may be used.

Author

J. R. M. Hosking jrmhosking@gmail.com

Details

In agglomerative hierarchical clustering, there are initially \(n\) clusters, each containing one data point, labeled \(1\) through \(n\) in the same order as the data points. At each stage of clustering, two clusters are merged. Their labels are saved in the merge array. The smaller of the two labels is used as the label of the merged cluster. After the \(i\)th stage of clustering there are \(n-i\) clusters. To find which data points belong to which clusters, use function cluinf.

References

Hosking, J. R. M., and Wallis, J. R. (1997). Regional frequency analysis: an approach based on \(L\)-moments. Cambridge University Press.

See Also

cluinf to get details of the clusters at a particular stage of the merging.

Examples

Run this code
## Clustering of gaging stations in Appalachia, as in Hosking
## and Wallis (1997, sec. 9.2.3)
data(Appalach)
# Form attributes for clustering (Hosking and Wallis's Table 9.4)
att <- cbind(a1 = log(Appalach$area),
             a2 = sqrt(Appalach$elev),
             a3 = Appalach$lat,
             a4 = Appalach$long)
att <- apply(att, 2, function(x) x/sd(x))
att[,1] <- att[,1] * 3
# Clustering by Ward's method
(cl<-cluagg(att))
# Details of the clustering with 7 clusters
cluinf(cl,7)

Run the code above in your browser using DataLab