Hierarchical Cluster Analysis (HCA)
Instead of fixing the number of clusters first, look at the order in which things merge.
Suppose a local government runs 12 libraries. Some libraries lend a lot of materials, some have high participation in children's programs, and others see heavy use of digital services. How could you group the libraries into a few operating types based on these differences?
You could use cluster analysis, which groups libraries with similar average characteristics. But you may not want to fix the number of clusters at three or four from the start. If you want to see the order in which similar libraries merge and then choose a suitable level of division, hierarchical cluster analysis (HCA) is useful.
HCA builds a stepwise cluster structure using the similarity or distance between observations. Results are usually shown as a dendrogram, and the height at which branches merge lets you see the distance or merging criterion between clusters.
In this article, we use a single case to look at distance measurement, linkage methods, standardization, dendrograms, choosing the number of clusters, cluster profiles and cautions for the analysis.
What is hierarchical cluster analysis?
Hierarchical cluster analysis builds a hierarchy either by starting from individual observations and merging them into larger clusters, or by starting from the whole set and dividing it into smaller groups.
In practice, agglomerative clustering, which starts with each observation as its own cluster and merges the closest ones first, is most common.
For example, if libraries A and B are the most similar, they are grouped first. Then, if C is similar to the AB cluster, an ABC cluster is formed, and this process repeats until all libraries are merged into one cluster. The result is not a classification table fixed at one number of clusters but a structure you can cut at various heights to examine several cluster solutions.
Conversely, divisive clustering starts with everything in one cluster and splits it step by step. Both approaches belong to hierarchical cluster analysis, but their specific algorithms and computational costs differ.
How is HCA different from K-Means?
K-Means takes a specified number of clusters K and forms clusters by reducing the distance between observations and each cluster's center.
Agglomerative HCA, by contrast, first builds the order in which observations merge, so you can examine several numbers of clusters in a single dendrogram.
| Aspect | Hierarchical cluster analysis (HCA) | K-Means |
|---|---|---|
| Basic result | Hierarchical structure showing the merge order | K clusters as specified |
| Number of clusters | Can be chosen after building the dendrogram | Specified before the analysis |
| Distance · similarity | Many distance measures and linkage methods | Usually based on Euclidean distance |
| Reassignment | Typical agglomerative algorithms never undo a merge | Membership can change during iterations |
| Main use | Exploring similarity structure among groups | Partitioning relatively large numeric data |
You cannot generalize that one method is better. Choose based on data size, cluster shape, the meaning of distance and explainability.
Real-world example: finding operating types of public libraries
Suppose we collected 2025 operating data for 12 public libraries in one city.
The goal of the analysis is not simply to rank operating performance but to group libraries with similar service characteristics.
| Variable | Unit | Meaning |
|---|---|---|
| Annual loans | thousand loans | Volume of lending-focused use |
| Annual program participants | thousand people | Scale of cultural and educational program participation |
| Monthly average digital service use | thousand uses | Use of e-resources and online services |
| Share of children's programs | % | Share of program participation in programs for children |
Larger libraries can show higher counts on every measure, so in a real analysis you should also consider converting to indicators per population or per registered member, or accounting for a size variable separately.
Here, to compare differences in operating profiles, we assume the four variables are standardized and then Euclidean distance and Ward linkage are applied.
The figures below are examples for understanding the concepts of the analysis.
Why standardize before the analysis?
In distance-based cluster analysis, the units and ranges of variables can strongly affect the results.
For example, if annual loans are in the tens of thousands and the share of children's programs ranges from 0 to 100%, differences in loans could determine almost all of the Euclidean distance on the raw data.
The standard way to reduce this problem is Z-score standardization.
zij = ( xij − x̄j ) ÷ sj
Here xij is library i's value on variable j, and x̄j and sj are the mean and standard deviation of variable j. Standardized values make different units comparable.
However, standardizing does not automatically make all variables equally important. You may give weights to variables that matter for the research purpose, and if there are many extreme values you can consider robust scaling methods.
Also, if variables overlap heavily, the same characteristic can be counted repeatedly in the distance calculation. So it is a good idea to look at the variable definitions and their correlations before standardizing.
How do you choose a distance measure?
HCA forms clusters based on the distances between observations.
Depending on the purpose of the analysis, you can use various measures such as Euclidean distance, Manhattan distance or correlation-based distance.
| Distance measure | Characteristics | When to consider |
|---|---|---|
| Euclidean distance | Square root of the sum of squared differences | Absolute differences in continuous variables |
| Manhattan distance | Sum of absolute differences | Comparing accumulated differences along each axis |
| Correlation-based distance | Compares the relative pattern of change across variables | When the shape of the profile matters more than its size |
If the standardized values of two libraries are A = (1, 0) and B = (0, 1), the Euclidean distance is √2 ≈ 1.414. These two coordinates are a simplified calculation example of the libraries' full data.
Because the order of the nearest libraries can differ with each distance measure, you should state the reason for your choice. In particular, Ward linkage is generally based on the increase in squared Euclidean error, so it should not be combined with an arbitrary distance measure and interpreted the same way.
Why does the linkage method matter?
Calculating the distance between two observations is a different problem from calculating the distance between two clusters that have already formed.
The rule that defines the distance between clusters is called the linkage method.
| Linkage | Criterion for comparing two clusters | Caution |
|---|---|---|
| Single linkage | Distance between the two closest points | Can produce long, chained clusters |
| Complete linkage | Distance between the two farthest points | Favors relatively compact clusters |
| Average linkage | Mean distance over all pairs of points between clusters | Reflects the average distance across whole clusters |
| Ward linkage | Increase in within-cluster sum of squares from merging | Suited to numeric data and Euclidean geometry |
Ward linkage merges based on how much within-cluster variation increases when two clusters are combined. So it can be useful for forming clusters of similar values. However, if clusters are very heterogeneous in size or shape, or there are many extreme values, the expected result may not appear.
In this example, we use the four standardized operating indicators and Ward linkage.
How do you read a dendrogram?
A dendrogram is a tree-shaped graph showing in what order observations and clusters were merged in agglomerative cluster analysis.
The horizontal axis shows the individual libraries or clusters, and the vertical axis shows the level at which clusters merge.
For example, if two libraries merge at a low height, their operating characteristics can be considered very similar under that linkage criterion. If two different large clusters merge at a high level, on the other hand, the difference between those clusters is relatively large.
Note that the vertical axis of a dendrogram does not always mean the original Euclidean distance itself. With Ward linkage in particular, depending on how the software defines it, the merge height shown may be related to the increase in the sum of squares. So check the axis label and the analysis settings together.
Cutting the dendrogram just below a merge where the height jumps sharply gives clusters that are distinct from each other. But a single visible gap does not objectively settle the number of clusters.
How do you decide the number of clusters?
HCA does not require you to fix the number of clusters first, but to report the libraries' operating types you must eventually decide how many clusters to use.
You can consider together the changes in merge height on the dendrogram, the silhouette score, the interpretability of the clusters and the minimum sample size per cluster. The silhouette score summarizes how close an observation is to its own cluster and how far it is from other clusters.
| Number of clusters | Average silhouette score | Comment |
|---|---|---|
| 2 | 0.38 | Different operating types are merged too much |
| 3 | 0.49 | Relatively good balance of separation and interpretation |
| 4 | 0.41 | Some clusters become very small |
| 5 | 0.35 | Results are overly fragmented |
With these results, you can choose three clusters. However, since there are only 12 libraries, you should not rely too much on small differences in the silhouette score. How much the results change with the distance measure or standardization method also matters.
How do you interpret the actual cluster results?
Suppose cutting the dendrogram into three clusters gives the following result.
The values below are cluster means in the original units to aid understanding, and are distinct from the standardized scores used in the analysis.
| Aspect | Cluster 1 | Cluster 2 | Cluster 3 |
|---|---|---|---|
| Number of libraries | 4 | 5 | 3 |
| Annual loans (thousands) | 125 | 76 | 58 |
| Annual program participation (thousand people) | 19 | 35 | 16 |
| Monthly digital use (thousand uses) | 42 | 25 | 68 |
| Share of children's programs | 22% | 49% | 18% |
Cluster 1 has relatively high loan counts and can be interpreted as lending-focused; Cluster 2 has high program participation and a high share of children's programs and can be interpreted as community-program-focused; and Cluster 3 has high digital service use and can be interpreted as digital-service-focused.
However, these names are not objective types assigned automatically by the algorithm. They are the researcher's interpretation after reviewing actual operating indicators and policy goals. Also, the fact that cluster means differ does not by itself let you conclude that the differences are statistically significant in the population or caused by operating strategies.
How do outliers and small samples affect the results?
Hierarchical cluster analysis can be affected by observations that are very far away.
For example, if just one library has extremely high loans or digital service use, that library may merge late with the other clusters in the dendrogram.
This may signal that a genuinely distinctive type of library exists, but it could also be due to a unit entry error or differences in how data were tallied. So check extreme and missing values before the analysis.
Also, typical agglomerative HCA algorithms do not split a merged cluster again at a later step.
An inappropriate early merge can affect the structure that follows. With small samples, a change in a single observation can greatly change cluster membership, so checking stability is important.
How do you check the stability of cluster results?
Because cluster analysis often has no ground-truth labels, it is best not to accept the result of a single analysis setting as a definitive classification.
For example, you can run sensitivity analyses like these: change the standardization method, apply average linkage in addition to Ward, or change which variables are included, and then check how similar the cluster memberships are. You can also exclude some observations or rebuild the clusters on bootstrap samples and examine cluster stability.
When comparing cluster results, you can use indices such as the Adjusted Rand Index (ARI). With very small samples, however, this index can also be highly variable, so along with the number it is good to check directly which libraries changed membership.
If the goal is to propose operationally meaningful types, it also helps to review the shared characteristics within each cluster and the differences from other clusters together with library staff.
Cautions for hierarchical cluster analysis
Choose the distance and linkage method together.
The distance measure decides what counts as similar, and the linkage method decides by what criterion clusters are merged. In particular, do not apply an arbitrary non-Euclidean distance with Ward linkage and interpret it as the same variance-minimizing procedure.
Check the units of variables and their overlap.
If you skip standardization, variables with large scales can dominate the distance, and including several variables carrying similar information can overweight a particular characteristic.
Do not decide the number of clusters from the dendrogram's shape alone.
Check not only merge heights but also silhouette scores, cluster sizes, interpretability and stability under other analysis settings.
Do not confuse closeness in the dendrogram with causation.
The fact that two libraries have similar operating indicators does not mean one library influenced the other.
Do not use cluster names as if they were objective diagnoses.
Cluster names are interpretations to describe observed characteristics, not evaluation scores that directly indicate the quality or relative performance of the libraries.
How do you report HCA results?
When reporting hierarchical cluster analysis results, present the sample size and analysis variables, missing-data handling, the standardization method, distance measure, linkage method, the basis for choosing the number of clusters, and the characteristics of each final cluster.
If possible, it is good to provide both the dendrogram and a table of cluster profiles.
Example of reporting results
To identify types of public libraries based on their operating characteristics, a hierarchical cluster analysis was conducted on 12 libraries using annual loans, number of program participants, digital service use and the share of children's programs. The analysis variables were standardized as Z-scores, and Euclidean distance with Ward linkage was applied. After reviewing the dendrogram, silhouette scores by number of clusters, cluster sizes and interpretability together, three clusters were selected.
Cluster 1 included 4 libraries with many loans and was interpreted as lending-focused; Cluster 2 included 5 libraries with high program participation and a high share of children's programs and was interpreted as community-program-focused; and Cluster 3 included 3 libraries with active digital service use and was interpreted as digital-service-focused. These results show that the libraries' operating characteristics are not explained by a single ranking but can be distinguished into different service profiles.
In real research, you should also report the distribution of variables in each cluster and the results of stability checks.
HCA shows not only the classification but also the process of grouping
Hierarchical cluster analysis shows how similar objects merge step by step based on the distances between observations.
Unlike K-Means, which fixes one number of clusters from the start, it lets you examine several levels of division in the dendrogram.
But the results can change with the distance measure and linkage method, standardization of variables, outliers and sample composition. So rather than settling the meaning of clusters from the dendrogram's shape alone, evaluate each cluster's characteristics and stability together.
The essence of HCA is not just dividing data into a few clusters but understanding the hierarchy in which the similarity structure among objects forms.