← 10. Patterns & segmentation
Hierarchical cluster analysis
Try this analysis →

Hierarchical Cluster Analysis (HCA)

Instead of fixing the number of clusters first, look at the order in which things merge.

Distance measuresLinkageDendrogramCluster stability

3 clustersMerge heightElmHollyJadeFirIvyLakeMapleOakAshCedarBirchDaleCommunity programs5 librariesDigital services3 librariesLending-focused4 libraries

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.

SECTION 1

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.

ABCD4 clustersABCD3 clustersABCD2 clustersABCD1 clusterAgglomerativeclosest firstDivisivesplit from the whole
Agglomerative vs. divisive

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.

SECTION 2

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.

AspectHierarchical cluster analysis (HCA)K-Means
Basic resultHierarchical structure showing the merge orderK clusters as specified
Number of clustersCan be chosen after building the dendrogramSpecified before the analysis
Distance · similarityMany distance measures and linkage methodsUsually based on Euclidean distance
ReassignmentTypical agglomerative algorithms never undo a mergeMembership can change during iterations
Main useExploring similarity structure among groupsPartitioning 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.

SECTION 3

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.

VariableUnitMeaning
Annual loansthousand loansVolume of lending-focused use
Annual program participantsthousand peopleScale of cultural and educational program participation
Monthly average digital service usethousand usesUse 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.

SECTION 4

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.

Raw data71%13%Z-score standardization27%24%26%23%Annual loansProgram participationDigital useChildren's share
Contribution to distance before and after standardization

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.

SECTION 5

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.

ABEuclidean √2Manhattan 2Correlation-based distanceSame shape of change means close
Comparing distance measures
Distance measureCharacteristicsWhen to consider
Euclidean distanceSquare root of the sum of squared differencesAbsolute differences in continuous variables
Manhattan distanceSum of absolute differencesComparing accumulated differences along each axis
Correlation-based distanceCompares the relative pattern of change across variablesWhen 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.

SECTION 6

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.

Single linkageclosest pointsComplete linkagefarthest pointsAverage linkagemean of all pairsWardincrease in sum of squares
Four linkage methods
LinkageCriterion for comparing two clustersCaution
Single linkageDistance between the two closest pointsCan produce long, chained clusters
Complete linkageDistance between the two farthest pointsFavors relatively compact clusters
Average linkageMean distance over all pairs of points between clustersReflects the average distance across whole clusters
Ward linkageIncrease in within-cluster sum of squares from mergingSuited 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.

SECTION 7

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.

0.02.24.36.58.7Merge heightElmHollyJadeFirIvyLakeMapleOakAshCedarBirchDaleLending-focusedCommunity programsDigital services
Dendrogram of 12 libraries

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.

SECTION 8

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.

2 clusters0.38merged3 clusters0.49balanced4 clusters0.41small cluster5 clusters0.35fragmented
Silhouette score by number of clusters
Number of clustersAverage silhouette scoreComment
20.38Different operating types are merged too much
30.49Relatively good balance of separation and interpretation
40.41Some clusters become very small
50.35Results 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.

SECTION 9

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.

AspectCluster 1Cluster 2Cluster 3
Number of libraries453
Annual loans (thousands)1257658
Annual program participation (thousand people)193516
Monthly digital use (thousand uses)422568
Share of children's programs22%49%18%
Cluster 1 · Lending, 4 librariesCluster 2 · Programs, 5 librariesCluster 3 · Digital, 3 librariesAnnual loansthousand loans1257658Program participationthousand people193516Digital usethousand uses/month422568Children's share%22%49%18%
Operating profile by cluster

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.

SECTION 10

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.

SECTION 11

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.

Reference resultZ-standardized · Euclidean · Ward · 3 clustersStandardizationRobust scalingLinkageAverage linkageVariablesDrop someSampleBootstrapCompare whether the same clusters hold when settings change
Checking cluster stability

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.

SECTION 12

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.

SECTION 13

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.

✓Wrap-up

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.

KEY TAKEAWAY

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.