RAISINS
  • Home
  • Get Started!
    • Data Analysis
    • Analysis of Experiments
    • Non Parametric tests
    • Statistical Genetics
    • Social Sciences
    • Sample size Calculator
    • Econometrics
    • Custom Tools
  • Learn
    • Tutorials
    • Quick Videos
    • Trainings New
    • Webinars
    • Wine
  • Team
  • Resources
    • Citation Info
    • Discussion
  • Pricing Plans
  • Go to AI Mode
  • Feedback
  • Contact us

On this page

  • 1 What is Hierarchical Cluster Analysis?
  • 2 Choosing how to scale your variables
  • 3 Distance Metrics
  • 4 Linkage Methods
  • 5 Finding the optimal number of clusters (k)
  • 6 Assumptions and things to check before clustering
  • 7 Getting to the module
    • 7.1 Computational Provenance & Reproducibility Record
  • 8 Preview mode and Quick Tour
  • 9 A working example
  • 10 How to prepare your data
    • 10.1 Preparing data in MS Excel
    • 10.2 Prepare using Create Data in RAISINS
    • 10.3 Download Model Datasets
    • 10.4 Creating a dataset using RA-One chat
  • 11 The Analysis tab
  • 12 Analysis Results
  • 13 Cluster plots
  • 14 Choosing k: the Optimal Clusters tab
  • 15 Heatmap
  • 16 HCPC: Hierarchical Clustering on Principal Components
  • 17 Cluster Comparisons: Tanglegram
  • 18 Chat with your data using RA-One
  • 19 FAQs
  • 20 View data
  • 21 Wrapping up

Hierarchical Cluster Analysis

Multivariate
Social-science

Hierarchical Cluster Analysis (HCA) widely used in Agricultural research … Read more …

Authors
Affiliations

Jithin Chandran

Statoberry LLP

Pratheesh P Gopinath

Kerala Agricultural University

Akhila P. S.

Kerala Agricultural University

Published

July 31, 2026

Abstract

Hierarchical Cluster Analysis (HCA) is a statistical method widely used in agricultural and social-science research to group similar observations into clusters based on their characteristics, building a tree-like structure (a dendrogram) to show how these groups form. In RAISINS you can perform HCA, explore it through a heatmap, run Hierarchical Clustering on Principal Components (HCPC), compare dendrograms with a tanglegram, and chat with your results using RA-One, all without writing a single line of code. This tutorial walks through the whole workflow using one worked example, from preparing your data to interpreting every table and plot the module produces.

1 What is Hierarchical Cluster Analysis?

Imagine you visit a field with 30 genotypes of a crop. At first glance every genotype looks different, but some are clearly more alike than others in yield, height, or seed characters. Instead of visually inspecting every pair, you measure a set of traits and organize genotypes into groups with similar trait patterns. Hierarchical Cluster Analysis (HCA) does exactly this: it starts by treating every observation as its own cluster, then repeatedly merges the two most similar clusters together, one merge at a time, until everything has been grouped into a single cluster. The order in which groups merge, and the similarity level at each merge, is shown in a tree-like diagram known as a dendrogram

TipIn short

Hierarchical agglomerative cluster analysis groups similar genotypes, treatments, or respondents based on their measured characters, and shows the grouping as a dendrogram. It is exploratory: nothing forces a “correct” number of clusters on you, you decide where to cut the tree, guided by the optimal-cluster methods covered in Section 5.

ImportantThere is no p-value here

Unlike many statistical tests, HCA has no null hypothesis and does not produce a significance test. It always creates a dendrogram, and once you choose a cut height, the observations are divided into clusters. Since clusters are always formed, you should evaluate whether they make practical sense by examining the dendrogram-fit diagnostics (Section Section 12) and the optimal number of clusters plots (Section Section 5), instead of relying on a significance threshold.

A little history: Sokal, Sneath, and the birth of numerical taxonomy
    Agglomerative hierarchical clustering grew out of numerical taxonomy, a movement led in the late 1950s by biologists Robert Sokal and Peter Sneath, who wanted to classify organisms using measured characters and explicit, repeatable rules rather than subjective expert judgement. The core linkage methods used today were formalised soon after: Joe H. Ward Jr. published the variance-minimising method that bears his name in 1963, and average and complete linkage were already in circulation from the same taxonomic literature. Because the method needs no assumption about the number of groups in advance, and the dendrogram it produces is easy to read even without statistical training, it remains one of the most widely used exploratory tools across biology, agriculture, and the social sciences.

2 Choosing how to scale your variables

HCA measures similarity using distance, and distance is dominated by whichever variable happens to have the largest numbers. If Assault is measured in the hundreds of arrests per 100,000 residents while UrbanPop is a percentage between 0 and 100, the raw distance calculation will be almost entirely driven by assault, drowning out the contribution of urban population. To keep every variable contributing fairly, RAISINS lets you scale the clustering variables before computing distances.

Method What it does When to use it
Z-score (default) Centres each variable at mean 0 and rescales to standard deviation 1 The safe general-purpose default for most datasets
Center Subtracts the mean only, keeps the original spread When the original units and relative variability should be preserved
Min-Max Rescales every variable to the 0–1 range When you want all variables to have exactly the same range
Unit length Rescales each variable to length 1 When only the pattern across variables matters, not magnitude
Robust Centres on the median and scales by the IQR When your data contain outliers that would distort a mean-based scaling
None Uses the raw values as measured Only when all variables already share the same meaningful unit and scale
TipIf you are unsure

Leave the scaling method at the default, Z-score. Switch to Robust if a quick look at your data shows one or two extreme values, and choose None only if every clustering variable you selected already shares the same meaningful unit.

See the exact formula and a worked example for each scaling method

The table above summarises what each method does. To see exactly how each one is calculated, take a single clustering variable measured on five genotypes: x = 10, 12, 14, 18, 26. Its mean is \(\mu = 16\), sample standard deviation \(\sigma = 6.3246\), median \(= 14\), \(Q_1 = 12\), \(Q_3 = 18\) (so \(IQR = 6\)), minimum \(= 10\), maximum \(= 26\), and Euclidean norm \(\lVert x \rVert_2 = \sqrt{1440} = 37.947\). Values below are rounded to 3 decimals.

None: \(x' = x\) → 10, 12, 14, 18, 26 (unchanged)

Center: \(x' = x - \mu\) → −6.000, −4.000, −2.000, 2.000, 10.000

Z-score (default): \(x' = \dfrac{x - \mu}{\sigma}\) → −0.949, −0.632, −0.316, 0.316, 1.581

Min-Max: \(x' = \dfrac{x - \min(x)}{\max(x) - \min(x)}\) → 0.000, 0.125, 0.250, 0.500, 1.000

Unit length: \(x' = \dfrac{x}{\lVert x \rVert_2}\) → 0.264, 0.316, 0.369, 0.474, 0.685

Robust: \(x' = \dfrac{x - \text{median}(x)}{IQR(x)}\) → −0.667, −0.333, 0.000, 0.667, 2.000

NoteWhy this matters

The most extreme observation (26) scales to 1.581 under z-score but only 2.000 under robust scaling, relative to the tighter middle spread of the data, because robust scaling never uses the mean or standard deviation. This is why robust scaling is the recommended choice when your clustering variables contain outliers.

3 Distance Metrics

Once your variables are scaled, RAISINS needs a rule for turning a row of numbers into a single “how far apart are these two genotypes” value. Five distance metrics are available: Euclidean, Manhattan, Maximum, Canberra, and Minkowski.

Let's understand the different distance metrics
  • Euclidean Distance
  • ️ Manhattan Distance
  • Maximum Distance
  • Canberra Distance
  • Minkowski Distance

Formula

\[\sqrt{\sum_i (x_i - y_i)^2}\]

Explanation

The straight-line distance between two observations, calculated using the Pythagorean theorem. It is the most familiar and widely used distance metric.

Formula

\[\sum_i |x_i - y_i|\]

Explanation

Also known as City Block Distance, it measures the total distance travelled by summing the absolute differences across all traits.

Formula

\[\max_i |x_i - y_i|\]

Explanation

Also called Chebyshev Distance, it considers only the largest difference among all measured traits.

Formula

\[\sum_i \frac{|x_i-y_i|}{|x_i|+|y_i|}\]

Explanation

A weighted distance measure that gives greater importance to differences when the values are small.

Formula

\[\left(\sum_i |x_i-y_i|^p\right)^{1/p}\]

Explanation

A generalised distance metric controlled by the parameter p.

  • p = 1 → Manhattan Distance
  • p = 2 → Euclidean Distance
  • Higher p gives more weight to larger differences.

Real-world analogy

Think of Minkowski distance as a flexible distance measure that can behave like different metrics depending on the value of p.

4 Linkage Methods

Distance tells you how far apart two individual genotypes are. Linkage tells you how far apart two whole clusters are, once each already contains more than one genotype, and it is this rule that decides which pair of clusters merges next as the dendrogram is built. RAISINS offers seven linkage methods: single, complete (the default), average, ward.D2, mcquitty, median, and centroid.

Let's understand the different linkage methods
  • Single linkage
  • Complete linkage
  • Average linkage
  • Ward.D2 linkage
  • McQuitty linkage
  • Median linkage
  • Centroid linkage

Formula

\[L(R,S) = \min_{i \in R,\; j \in S} D(i,j)\]

Explanation

For two clusters R and S, single linkage returns the minimum distance between any pair of points, one from each cluster. This method creates long, chain-like clusters because it is sensitive to outliers and can connect clusters based on a very small number of close points.

Where

  • D(i, j): distance function between points i and j
Figure 1: Diagram illustrating single linkage — the shortest link between any two points across two clusters

Formula

\[L(R,S) = \max_{i \in R,\; j \in S} D(i,j)\]

Explanation

For two clusters R and S, complete linkage returns the maximum distance between any pair of points. It tends to create compact and spherical clusters because it is more sensitive to outliers and tries to make sure the clusters are not too far apart.

Where

  • D(i, j): distance function between points i and j
Figure 2: Diagram illustrating complete linkage — the farthest link between any two points across two clusters

Formula

\[L(R,S) = \frac{1}{n_R \times n_S} \sum_{i=1}^{n_R} \sum_{j=1}^{n_S} D(i,j)\]

Explanation

Average linkage returns the average distance between all pairs of points from two clusters. This method maintains a balance between single and complete linkage by considering all pairs of points, not just the closest or farthest point. It usually results in clusters that are moderately compact.

Where

  • nR: number of data points in R
  • nS: number of data points in S
Figure 3: Diagram illustrating average linkage - the mean of all pairwise distances between the two clusters

Formula

\[L(R,S) = \frac{n_R \times n_S}{n_R + n_S} \sum_{i=1}^{n_R} \sum_{j=1}^{n_S} D(i,j)\]

Explanation

Ward’s linkage calculates the distance between two clusters by looking at the total spread, or variance increase, when the clusters are combined. This method creates compact, well-separated clusters by making sure that data within each cluster stays as similar as possible.

Where

  • nR and nS: sizes of clusters R and S
  • D(i, j): distance between points i ∈ R and j ∈ S
Figure 4: Diagram illustrating Ward’s linkage - the increase in within-cluster variance from merging two clusters

A variant of average linkage that uses a simple average of distances weighted by cluster size, giving a compromise that accounts for clusters of different sizes as they merge.

Figure 5: Diagram illustrating McQuitty linkage merging between the two clusters

Formula

\[L(R,S) = \underset{i \in R,\; j \in S}{\text{median}}\; D(i,j)\]

Explanation

For two clusters R and S, median linkage returns the median distance between a variable in one cluster and a variable in the other cluster, calculated from the pairwise distance matrix between the two clusters. It is more robust to skewed data than average linkage, but can produce non-monotonic merges (reversals) in the dendrogram.

Where

  • D(i, j): distance function between points i and j
Figure 6: Diagram illustrating median linkage - the median of the pairwise distance matrix between the two clusters

Formula

\[L(R,S) = D(\bar{R}, \bar{S})\]

Explanation

Centroid linkage calculates the distance between two clusters based on the distance between their central points, i.e. the average of all points in the cluster. This method works well when clusters are round or evenly shaped, but it may not be the best choice for irregularly shaped clusters.

Where

  • R̄ and S̄: the centroids (mean points) of clusters R and S
  • D(R̄, S̄): the distance between the centroids of clusters R and S
Figure 7: Diagram illustrating centroid linkage — the distance between the centroids of both clusters.

5 Finding the optimal number of clusters (k)

The dendrogram alone does not tell you where to “cut” the tree. In RAISINS, the default optimal number of clusters is determined using the Elbow Method, which identifies the point at which increasing the number of clusters yields diminishing improvements in within-cluster homogeneity. However, the choice of the final number of clusters should ultimately be guided by the researcher’s domain knowledge, study objectives, and interpretability of results. Users are therefore encouraged to explore alternative validation approaches, such as the Silhouette Method and the Gap Statistic, available together in the Optimal Clusters tab (Section 14), each downloadable and each drawn against a maximum number of clusters that you control with a slider.

PLACEHOLDER: generic Elbow Method diagram

PLACEHOLDER: generic Elbow Method diagram

5.1 The Elbow Method

Plots the within-cluster sum of squares (WSS) against increasing k. WSS always falls as k grows, but the rate of improvement slows sharply once you pass the natural number of groups, showing up as a bend, or elbow, in the curve.

In RAISINS: The bend is detected automatically and pre-fills the Number of clusters box with it, always free to override.


5.2 The Silhouette Method

Measures, for each observation, how much closer it sits to its own cluster than to the next-nearest one, averaged into a score from −1 to 1, higher meaning tighter, more separated clusters.

In RAISINS: The peak is identified automatically and presented as an alternative recommended number of clusters.

Silhouette Method

Silhouette Method


Gap Statistic

Gap Statistic

5.3 The Gap Statistic

Compares your data’s clustering tightness against what you would get from data with no real structure at all (a reference distribution). A larger “gap” at a given k means your data cluster far more convincingly than random noise would.

In RAISINS: The recommended k from the Gap Statistic is displayed alongside the other two to help you decide.

TipThese three will not always agree, and that is normal

RAISINS pre-fills the Number of clusters box using the elbow method as a fast default, but the silhouette and gap-statistic plots in Section 14 are there so you can cross-check that choice. Disagreement between the three is common and expected; let your subject-matter knowledge about how many groups you actually expect make the final call.

6 Assumptions and things to check before clustering

Requirement What it means What if it fails?
Numeric variables Every clustering variable must be a proper number, not text or a category Recode categorical variables, or exclude them from the clustering variables
No missing values Distances cannot be computed to a missing value Clean or impute the dataset before uploading
Comparable scales Variables in very different units can dominate the distance calculation RAISINS handles this through the scaling methods in Section 2
Unique observation labels Each row needs its own identifier so results can be traced back to it Remove duplicate labels before uploading
NoteNote

RAISINS validates the label and variable columns automatically once selected, before it lets you run the analysis. If the dendrogram or plots in Section 13 suggest genuinely round, evenly-sized groups rather than a chain-like or nested structure, RAISINS’s K-Means Cluster Analysis module is a companion tool built for exactly that case (Section 21).

7 Getting to the module

Visit RAISINS and navigate to Cluster Analysis under Data Analysis, as shown in Figure 8.

Figure 8: Cluster Analysis in RAISINS

7.1 Computational Provenance & Reproducibility Record

CPRR (Computational Provenance & Reproducibility Record) provides a transparent, comprehensive record of the computational workflow behind this module, the R version and exact version of every package used, the specific function behind each reported result, every default parameter and decision rule applied, and fully runnable R code that reproduces each analytical step so you can independently verify the results. It carries its own DOI.

To cite the platform itself in a paper, thesis, or report, use the RAISINS citation, available in APA, Harvard, and BibTeX formats at www.raisins.live/citation.html. That is the primary reference, and for most manuscripts it is all you need.

The CPRR for Cluster Analysis is at www.raisins.live/module_record/cluster.html.

8 Preview mode and Quick Tour

Before subscribing, you can explore the whole module using Preview mode, available from the Welcome page. Preview mode loads built-in datasets so you can try clustering, all eight dendrogram plot types, the Heatmap, HCPC, Cluster Comparisons without uploading your own data. First-time users are also offered a Quick Tour, an interactive walkthrough that highlights each control and explains what it does; you can retake it at any time from the Quick Tour tab.

9 A working example

We will explain HCA using one worked example that we will carry through the rest of this tutorial. Consider the classic USArrests dataset: 50 U.S. states described by four variables, Murder, Assault, and Rape (arrests per 100,000 residents), and UrbanPop (percent of the population living in urban areas). The goal is to group the states based on these characters. If you work in agriculture, your goal is the same, grouping genotypes or treatments based on the variables under study.

Figure 9: Model dataset: USArrests dataset

Two terms you will see throughout this tutorial: Labels are the row identifiers (here, the state names), and Variables are the measured characters used for clustering (here, the four traits above).

10 How to prepare your data

Arranging data for upload is simple: prepare a single-sheet file exactly like Figure 9, with no blank rows above the data and every column named. You have four routes to get there:

  1. Create your dataset in MS Excel
  2. Build your dataset directly within the RAISINS app (Create Data)
  3. Use the Model datasets in RAISINS (Datasets) as a reference
  4. Create your dataset using the RA-One chat assistant

10.1 Preparing data in MS Excel

Open a new blank sheet in MS Excel, using a single sheet only, and begin entering data from cell A1 with no blank rows above it. The first row must contain the column names. Column 1 holds the treatment or label ID, and there should be no repetition in the label IDs (if you have replications, use the mean values). From Column 2 onward, enter each variable under study as its own numeric column, for example Murder, Assault, UrbanPop, Rape. You can name the columns however you like, but avoid spaces and special characters.

Create dataset in MS Excel: USArrests dataset

Create dataset in MS Excel: USArrests dataset

If you have any doubt about saving a file as CSV or the basics of data preparation, see our tutorial on getting started here.

10.2 Prepare using Create Data in RAISINS

Navigate to the Create Data tab, enter the levels of Factor A, Factor B, Factor C, and the number of characters under study, then click Create. A model data-entry template appears, which you can fill in directly or paste from an existing Excel file. Once complete, click Download CSV and upload the file under the Analysis tab.

Figure 10: Creating a dataset within RAISINS

10.3 Download Model Datasets

If you are unsure of the required format, or want to explore the module before uploading your own data, navigate to the Datasets tab and download the reference CSV there. Use it as a layout guide, or upload it directly to try the analysis end to end.

Download model datasets within RAISINS

Download model datasets within RAISINS

10.4 Creating a dataset using RA-One chat

RA-One, the built-in chat assistant, can build a properly formatted dataset through a short conversation. Open RA-One from the chat icon or the RA-One tab, tell it how many observations and clustering variables you need, and it generates a dataset in the required format that you can review, download as CSV, and upload under Analysis.

Figure 11: RA-One chat generating a dataset template on request, showing the conversation and the resulting downloadable CSV

11 The Analysis tab

Figure 12 walks through the whole Analysis tab, from uploading your file to reading the first result, follow the numbered callouts on the image as you read:

Figure 12: Upload the dataset, select the label and clustering variables, run the analysis, and choose the linkage, distance, and scaling method
  1. Upload file - click Browse in the sidebar and select your prepared CSV or Excel file; the sidebar shows Upload complete once it has loaded.
  2. Select Labels - choose your unique label or observation column from the Select the Labels or Observations column picker (Location in our worked example).
  3. Select Clustering Variables - choose at least two numeric variables from the Select the Clustering Variables picker (Murder, Assault, UrbanPop, Rape in our worked example).
  4. Click on Run Analysis! - the red Run Analysis! button starts the clustering.
  5. Select Linkage Method - once results appear, the control panel on the right lets you change the Linkage method (Section 4) from the default complete.
  6. Select Distance Method - the Distance dropdown next to it lets you change the distance metric (Section 3) from the default euclidean.
  7. Select Method - the Scaling dropdown lets you change the scaling method (Section 2) from the default zscore; Decimal points and Number of clusters sit alongside it, the latter pre-filled with the elbow method’s suggestion from Section 5 but always editable.
  8. Results - the auto-generated Hierarchical Clustering summary and the results tables (Section 12) appear directly below the control panel.

For our worked example, the default complete linkage and euclidean distance on the 50-state USArrests dataset, scaled with z-score, produced a dendrogram whose elbow-method suggestion was two clusters, shown in Figure 13. You are always free to change the number of clusters, the linkage, the distance metric, or the scaling method and re-examine the result.

Figure 13: Colour Coded Clusters dendrogram of the USArrests worked example
Step-by-step: how to read a dendrogram
  1. Start at the bottom - each leaf represents a single observation (here, a state).
  2. Follow the lines upward - the first merges connect the most similar items; a low connection height means those points were very close on the chosen distance measure.
  3. Merging clusters - as you go higher, clusters combine with other clusters, each branching a further step of grouping, like building a family tree for your data.
  4. Branch heights - the height at which two branches merge shows how similar the merged groups were; lower connections mean more similar groups.
  5. Deciding the number of clusters - “cutting” the tree horizontally at a chosen height divides the data into clusters, one per branch below the cut line. RAISINS’s Number of clusters box does this cut for you.

12 Analysis Results

Directly below the dendrogram, RAISINS writes an automatically generated plain-language summary titled Hierarchical Clustering. For our worked example it reads: clustering was performed with the complete linkage method and euclidean distance metric; the number of clusters was identified through the elbow method, resulting in 2 clusters; the uploaded dataset was initially scaled using the z-score method; and each cluster groups similar observations based on the selected numeric variables, with branches in the dendrogram colour-coded to reflect cluster membership. Beneath it, five results tables appear in the same tab, each with an info button explaining what it shows.

Distance Matrix

Figure 14: Distance Matrix (euclidean method) for USArrests

The pairwise dissimilarity between every pair of states on the chosen distance metric, computed on the scaled clustering variables (Section 2), the raw material every later merge in the dendrogram is built from. Smaller values mean two states are more alike on the clustering variables, for example Alabama and Georgia sit at just 1.13, while Alabama and California sit at 3.26.

Cluster Means

The average of each clustering variable within each cluster, computed on the original, unscaled units even though the clustering itself runs on scaled data, summarising the typical characteristics of that cluster. In our run, cluster 1 averages Murder = 12.33, Assault = 259.32, UrbanPop = 68.32, Rape = 29.22, while cluster 2 averages Murder = 5.00, Assault = 116.48, UrbanPop = 63.84, Rape = 16.34, a high-crime cluster and a comparatively low-crime cluster.

Figure 15: Cluster Means Statistics for USArrests

Intra-cluster Statistics

The average pairwise distance among members of the same cluster, a measure of how compact or homogeneous each cluster is. Lower values mean the states inside that cluster closely resemble one another, here cluster 1 has an intra-cluster distance of 2.09 and cluster 2 of 1.84, so cluster 2 is the slightly tighter of the two.

Intra-cluster Statistics for USArrests

Intra-cluster Statistics for USArrests

Inter-cluster Statistics

The average distance between every pair of different clusters, one row per cluster pair, a measure of how well separated the clusters are from each other. Higher values mean the clusters are more distinct, in our run the inter-cluster distance between cluster 1 and cluster 2 is 3.34, comfortably larger than either intra-cluster distance above, a good sign the two-cluster split is meaningful.

Inter-cluster Statistics for USArrests

Inter-cluster Statistics for USArrests

Dendrogram fit: Cophenetic Distance and Correlation

Two further tables report the cophenetic distance, the distance implied between every pair of states purely by where they merge in the dendrogram, and the single cophenetic correlation between that implied distance and the original distance matrix above. A cophenetic correlation close to 1 means the dendrogram faithfully represents the real distance structure in your data; a low value is a signal to try a different linkage method (Section 4) before trusting the tree. Our worked example returns a cophenetic correlation of 0.70, a reasonably faithful, if not perfect, summary of the underlying distances.

Cophenetic Distance Matrix and Correlation for USArrests

Cophenetic Distance Matrix and Correlation for USArrests
TipThere is still no p-value

As with the dendrogram itself, none of these five tables carries a significance test. Use the cophenetic correlation to judge whether the tree is a faithful summary of the distances, and the cluster means and intra-/inter-cluster statistics to describe what the clusters actually contain.

13 Cluster plots

The Plots & Graphs tab offers eight complementary dendrogram styles, all built from the same underlying clustering. Each plot comes with a gear icon at the top-left corner, allowing you to customise titles, fonts, colours, and sizes. You can also download these plots in high-quality PNG (300 dpi), JPEG, TIFF, PDF, and SVG formats for use in reports and publications.

From Figure 16 to Figure 23, you can see the eight dendrogram styles available in the Plots & Graphs tab of the Cluster Analysis module in RAISINS. Each is visually illustrated and accompanied by a clear description below — hover over any plot thumbnail to read it.

Figure 16: Colour Coded Clusters

Colour Coded Clusters (k = 2) — Branches and tip labels are coloured by cluster assignment without drawing rectangles, an easy first look at which states ended up in which group.

Figure 17: Cluster Dendrogram

Cluster Dendrogram (k = 2) — The same colour-coded dendrogram, but with a rectangle drawn around each cluster’s branches, making the grouping easier to trace visually for large datasets.

Figure 18: Rectangular Dendrogram

Rectangular Dendrogram (k = 2) — Clusters are enclosed in rectangular boxes drawn on the dendrogram to make the cluster boundaries explicit at a glance.

Figure 19: Vertical Dendrogram

Vertical Dendrogram (k = 2) — The classic, user-friendly layout with observations along the bottom and merges represented by upward vertical lines.

Figure 20: Horizontal Dendrogram

Horizontal Dendrogram (k = 2) — The same structure rotated 90 degrees, observations run down the vertical axis and branches extend left to right, useful for datasets with many labels.

Figure 21: Base Dendrogram

Base Dendrogram (k = 2) — The traditional base-graphics tree, showing the nested grouping of states from individual leaves up to the full merged tree.

Figure 22: Ward’s Dendrogram

Ward’s Dendrogram (k = 2) — The same tree drawn specifically to highlight Ward’s linkage, which minimises the increase in within-cluster variance at each merge, producing compact, evenly sized groups.

Figure 23: Circular Dendrogram

Circular Dendrogram (k = 2) — A radial, space-efficient layout that arranges the branches in concentric circles, giving a 360-degree view of the grouping, useful for datasets with many observations.

NoteSelection of cluster number

The default cluster number is calculated using the elbow method (Section 5). Since cluster analysis is exploratory, you can change Number of clusters at any time, that change is reflected in every one of these eight plots.

14 Choosing k: the Optimal Clusters tab

Figure 24: Optimal Clusters Tab

The Optimal Clusters tab lets you set Select maximum cluster to display with a slider (1 to 50 states, defaulting to 5), then shows the three diagnostic plots from Section 5 on demand, each downloadable in PNG, JPEG, TIFF, PDF, or SVG format.

Elbow Method for USArrests, within-cluster sum of squares against the number of clusters

Elbow Method for USArrests, within-cluster sum of squares against the number of clusters

Silhouette Method for USArrests, average silhouette width against the number of clusters

Silhouette Method for USArrests, average silhouette width against the number of clusters

Gap Statistic for USArrests against the number of clusters

Gap Statistic for USArrests against the number of clusters

Read the elbow plot by looking for the bend where the curve stops falling steeply; that is the suggested k. Read the silhouette plot by looking for the highest peak. Read the gap statistic by looking for the smallest k whose gap value is within one standard error of the largest gap observed.

15 Heatmap

A heatmap represents the clustering-variable values as a colour-coded matrix, with rows and columns reordered according to the hierarchical clustering result so that similar states and similar variables sit next to one another. Open the Heatmap tab (Figure 25) after running the analysis; the gear icon lets you customise the colour scheme, cell borders, cell size, value labels, and whether rows and columns are individually clustered.

Figure 25: Heatmap of the USArrests worked example, rows and columns reordered by the hierarchical clustering result

Blocks of similar colour indicate states or variables with related profiles, while the accompanying row and column dendrograms show their hierarchical relationships. By default the heatmap uses the same scaling, linkage, and distance chosen in the Analysis tab, for our worked example that is z-score scaling with complete linkage and euclidean distance, resulting in the same 2 clusters seen in Section 12. Download the heatmap in high-quality PNG, JPEG, TIFF, PDF, or SVG format for reports or presentations.

16 HCPC: Hierarchical Clustering on Principal Components

HCPC is a hybrid approach combining Principal Component Analysis (PCA) with hierarchical clustering. PCA first summarises the correlated clustering variables into a smaller set of uncorrelated components that retain most of the original variance; hierarchical clustering (Ward linkage, consolidated with a k-means pass) is then performed on those components instead of the raw variables. This reduces noise from correlated variables and can sharpen cluster separation. The results in the HCPC tab are entirely separate from the Analysis Results tab above, they come from a different clustering run on the principal-component space, not the cutree-based clusters from Section 12.

When to use HCPC?
  • When you have many continuous, correlated clustering variables and want to reduce dimensionality before clustering.
  • When you want an integrated PCA + hierarchical clustering + k-means refinement pipeline instead of a single method.
  • When you want richer visualisations, factor maps and chord diagrams, for presenting the grouping.
Difference between HCPC and classical HCA
  • HCPC clusters the uncorrelated principal components; classical HCA (Section 12) clusters the raw variables directly.
  • HCPC combines PCA, hierarchical clustering, and a k-means consolidation step; classical HCA only performs hierarchical clustering.
  • HCPC produces a factor map and chord diagrams in addition to a dendrogram; classical HCA’s main output is the dendrogram and the tables in Section 12.

After uploading your data, selecting your labels and clustering variables, and clicking Run Analysis, open the HCPC tab. Six tables appear first, in order: PCA eigenvalues & variance explained, variable contributions, variable correlations with components, the Clustering Summary (standardized cluster means from the PCA input data), the top variables per cluster, and the cluster quality indicators, followed by five plot buttons in the order HCPC Dendrogram, Factor Map, HCPC 3D Dendrogram, Chord Diagram, and Chord (Means).

Eigen Values PCA

Figure 26: Eigen Values PCA for USArrests: eigenvalue, percentage variance, and cumulative variance per component

The eigenvalue is the variance captured by each principal component; components with an eigenvalue greater than 1 are typically the meaningful ones. In our worked example, component 1 alone captures 62.01% of the total variance (eigenvalue 2.48), and component 2 adds a further 24.74%, so the first two components together already explain 86.75% of the variance, comp 3 and comp 4 explain the remaining 8.91% and 4.34%.

Cluster-wise Contribution

Figure 27: : Cluster-wise Contribution table for USArrests, variable contribution to each PCA dimension

This table shows how much each clustering variable contributes to each principal-component dimension. In our run, UrbanPop dominates Dim.2 (76.18% contribution) while Murder, Assault, and Rape all load heavily on Dim.1 (28–34% each), confirming that Dim.1 is essentially an overall “crime intensity” axis and Dim.2 an “urbanisation” axis.

Correlation Table

Figure 28: : Correlation Table for USArrests, variable correlations with each PCA component

This table reports each clustering variable’s correlation with each component, from −1 to 1. Assault (0.92) and Rape (0.86) correlate most strongly with Dim.1, while UrbanPop (0.87) correlates most strongly with Dim.2, the same pattern as the contributions table above, expressed as a signed correlation rather than a percentage.

Clustering Summary

Figure 29: : Clustering Summary for USArrests, standardized cluster means from the PCA input data

The standardized (z-score) mean of each clustering variable within each HCPC cluster. Cluster 1 sits below the overall average on every variable (Murder −0.67, Assault −0.68, UrbanPop −0.13, Rape −0.56), while cluster 2 sits above average on all four (Murder 1.00, Assault 1.01, UrbanPop 0.20, Rape 0.85), a similar high-crime versus low-crime split to the classical HCA results in Section 12, though HCPC clusters on the principal components rather than the raw variables.

Figure 30: Top Variables by Cluster for USArrests, ranked by absolute v.test

For each cluster, the variables with the largest absolute v.test are shown, alongside the mean and standard deviation within the cluster versus overall, and a p-value for the variable’s contribution. Larger absolute v.test and smaller p-value mean that variable more strongly characterises that particular cluster. In our run, Assault is the strongest characterising variable for both clusters (v.test of −5.85 for cluster 1, +5.85 for cluster 2), followed closely by Murder and Rape, all with p-values of 0.00.

Figure 31: Cluster Quality Indicators for USArrests: Total, Within, and Between sum of squares

These four indicators are computed in the PCA-coordinate space, not on the raw or scaled variables directly. Total_SS is the total variability across all observations in that PCA space, representing overall data dispersion. Within_SS is the variation of points around their own cluster’s centroid, a compactness measure. Between_SS is the variation between cluster centroids, how distinct the clusters are. The Between/Total ratio is a separation indicator, higher values mean the clusters are better separated from one another. In our worked example, Total_SS = 200.00, Within_SS = 104.96, Between_SS = 95.04, giving a Between/Total ratio of 0.48, close to half the total variance is explained by the two-cluster split.

From Figure 32 to Figure 36, you can see the five HCPC visualisations available in RAISINS. Each is visually illustrated and accompanied by a clear description below — hover over any plot thumbnail to read it.

Figure 32: HCPC Dendrogram

HCPC Dendrogram — Hierarchical clustering performed in the principal-component space rather than on the raw variables, showing how observations merge based on their PCA coordinates.

Figure 33: Factor Map

Factor Map — Plots every state in the space of the first two principal components, coloured and enclosed by cluster. Well-separated, non-overlapping regions indicate a clean grouping, while heavy overlap suggests the clusters are not clearly distinct.

Figure 34: HCPC 3D Dendrogram

HCPC 3D Dendrogram — The dendrogram projected onto the PCA factor map, letting you see the cluster structure and the underlying component space together.

Figure 35: Chord Diagram

Chord Diagram — Visualises the relationship between your original variables and the HCPC clusters. Wider ribbons mean a variable is more characteristic of that cluster, weighted by its v.test statistic and normalised within each cluster.

Figure 36: Chord Diagram (Means)

Chord (Means) — The same variable-to-cluster relationship as the Chord Diagram, but weighted by cluster mean values instead of v.test.

The Factor Map (Figure 33) plots every state in the space of the first two principal components, coloured and enclosed by cluster, well-separated, non-overlapping regions indicate a clean grouping, while heavy overlap suggests the clusters are not clearly distinct on the variables you selected. The Chord Diagram (Figure 35) visualises the relationship between your original variables and the HCPC clusters. The outer ring shows two types of segments, your dataset’s variables and the clusters, and the ribbons connecting them represent the strength of association: wider ribbons mean a variable is more characteristic of that cluster, weighted by its v.test statistic and normalised within each cluster so you can compare relative importance. In our worked example, Assault and Murder form the widest ribbons into both clusters, consistent with them being the top variables by v.test above. Chord (Means) presents the same relationship, but weighted by cluster mean values instead of v.test.

17 Cluster Comparisons: Tanglegram

Every choice in Section 4 and Section 3 changes the resulting tree, so it helps to compare two runs side by side. The Cluster Comparisons tab lets you pick a Distance measure and Linkage method independently for Method 1 and Method 2 (the defaults compare average linkage against ward.D2, both on euclidean distance), plus a Number of clusters (k) to highlight slider (2 to 20, defaulting to 6), then draws a tanglegram, two dendrograms facing each other with lines connecting the same state on each side.

Figure 37: Cluster Comparisons tab for USArrests, showing the Method 1 / Method 2 distance and linkage selectors, the k-to-highlight slider, and the resulting tanglegram with its entanglement score

Above the plot, RAISINS writes an automatic plain-language summary of the comparison. Straight, uncrossed connecting lines mean the two linkage/distance choices grouped the states almost identically; heavy crossing means the two methods disagree about which states belong together. This is quantified by the entanglement score, from 0 (the two dendrograms align perfectly) to 1 (maximal tangling), shown beneath the plot. For the default average vs ward.D2 comparison on USArrests, both at k = 6, the entanglement score is 0.0754, close to 0, so the two linkage methods agree closely on this dataset even though their formulas differ.

TipUse this before committing to a linkage method

If two very different linkage methods (say, single vs. Ward.D2) produce a low-entanglement tanglegram, your grouping is robust to that choice, a reassuring sign. A high entanglement score means the linkage method genuinely matters for your data, and it is worth reading Section 4 again before deciding which one to report.

Figure 38: Linkage Method Correlation (cophenetic) heatmap across the six linkage methods, computed on USArrests

Below the tanglegram, the Linkage Method Correlation (Cophenetic) heatmap compares all six standard linkage methods (single, complete, average, centroid, median, Ward) at once, on a distance metric you choose, using the correlation between their cophenetic distances. This gives a quick overview of which linkage choices tend to agree with each other, complementing the two-method tanglegram above. On USArrests with euclidean distance, complete and Ward agree almost perfectly (correlation 0.94), while median linkage stands apart from every other method (correlations of just 0.26–0.33), a sign that median linkage is producing a noticeably different tree structure on this dataset.

Linkage Method Correlation (cophenetic) heatmap across the six linkage methods, computed on USArrests

Linkage Method Correlation (cophenetic) heatmap across the six linkage methods, computed on USArrests

18 Chat with your data using RA-One

RA-One is the built-in conversational assistant for the Cluster Analysis module, available from the RA-One tab or the chat bubble. You ask questions in plain language and it answers using your own results.

Figure 39: PLACEHOLDER: Chatting with RA-One about the cluster analysis results, showing a plain-language answer grounded in the actual run

Within a single conversation, RA-One can:

  • Interpret your results - explain what the distance matrix, cluster means, intra-/inter-cluster statistics, cophenetic correlation, or the HCPC tables mean for your specific run.
  • Generate any of the eight dendrogram plot types from Section 13 on request, colour coded, rectangular, vertical, horizontal, base, Ward’s, circular, or the coloured-rectangle cluster dendrogram, styled and downloaded directly in the chat.
  • Draw the tanglegram or the linkage correlation heatmap from Section 17 on request, and refine an existing plot (palette, labels, branch colour, and more) by simply asking for changes.
  • Prepare your data - build a correctly formatted dataset template (Section 10.4) or fetch a model dataset (Section 10.3) so you can try the module immediately.
  • Answer format and replication questions - how many columns you need, how to lay out labels versus variables, and similar general questions about preparing a file for this module.
TipOne assistant, several jobs

Within a single conversation, RA-One can interpret your clustering results, produce any of the eight dendrogram styles or the tanglegram, build a data template, and fetch a model dataset, so a routine HCA session can largely be conducted without leaving the chat window.

19 FAQs

The module includes a dedicated FAQs tab that clarifies common doubts, linkage and distance choices, scaling, reading a dendrogram, and more, with detailed answers and tips for a smooth experience.

Figure 40: FAQs for Cluster Analysis Module

20 View data

View Data is the primary diagnostic tool for confirming data integrity before analysis. When you upload your dataset, RAISINS performs an automated health check: it confirms your chosen label column contains unique, non-numeric values with no duplicates, that all selected clustering variables are numeric, and that there are no missing values, since distances cannot be computed to a missing cell. Use this tab any time the Analysis tab reports a problem with your file.

View Data: the label column highlighted yellow, all numeric clustering variables highlighted green

View Data: the label column highlighted yellow, all numeric clustering variables highlighted green

21 Wrapping up

Hierarchical Cluster Analysis rests on one simple mechanism: start with every observation in its own group, repeatedly merge the two most similar groups, and record every merge as a dendrogram. Everything else in this tutorial, scaling, distance metrics, linkage methods, the optimal-k plots, HCPC, the tanglegram, exists to help you make the judgment calls the algorithm itself cannot: how to make your variables comparable, which linkage and distance genuinely suit your data, and where to cut the tree.

If your data instead form clean, evenly sized, roughly spherical groups and you already know how many groups you expect, RAISINS’s K-Means Cluster Analysis module is a companion tool built for exactly that case, and it uses the same scaling options described in Section 2. If you get stuck at any point, RA-One is available 24 × 7, or write to us at [email protected].

Explore

  • Data analysis
  • Feedback

Policies

  • Privacy policy
  • Data policy
  • Refund policy

Contact

  • Contact us
  • Team
  • Statoberry LLP
Statoberry LLP
© 2026 Statoberry LLP. All rights reserved.
Making statistics sweet — www.raisins.live
RAISINS