Skip to main content
v2026.11,610 entries · CC-BY 4.0

Cluster Analysis in SPSS: Hierarchical vs. K-Means

When to use hierarchical clustering (exploratory, dendrogram, unknown cluster count) versus K-means clustering (specified cluster count, larger datasets) in SPSS, and how to read each procedure’s output.

Ask about Cluster Analysis in SPSS: Hierarchical vs. K-Means

Answers are drawn from this guide and the rest of the CASRAI corpus, with a link to every source.

Answers are AI-generated from CASRAI’s own published pages and can be wrong, so check the linked sources before relying on one; your question is logged without personal data — never sold, never used to train a third-party model — to show us what CASRAI is missing, so please do not type personal or confidential details. How we use this

Written and maintained by CASRAI Editorial Board

Last updated

SPSS puts two different clustering procedures under Analyze > ClassifyHierarchical Cluster and K-Means Cluster — and they answer different questions. Hierarchical clustering is exploratory: it builds a full nested tree of every possible grouping and lets you decide afterward how many clusters make sense, which is why it produces a dendrogram. K-means clustering does the opposite: you tell it up front how many clusters you want, and it partitions the data to fit that number, which is why it scales to much larger datasets than hierarchical clustering can handle. Picking the wrong one for your situation doesn’t just waste time — it can produce a solution SPSS will happily print output for even when the method is a poor fit for what you’re trying to find.

Before either procedure: standardize your variables

Both hierarchical and K-means clustering group cases based on distance — usually squared Euclidean distance by default in SPSS. Distance is scale-dependent: a variable measured in the thousands (income) will dominate the distance calculation over a variable measured on a 1–5 scale (a survey item) purely because of its larger numeric range, not because it’s more important. If your clustering variables are on different scales, standardize them first.

The most common route in SPSS is Analyze > Descriptive Statistics > Descriptives, then check Save standardized values as variables before clicking OK. This adds a new Z-prefixed variable for each one you selected (e.g. Zincome), converted to a mean of 0 and standard deviation of 1. Use these standardized variables — not the raw ones — as the clustering variables in either procedure below. (See Z-score: formula and worked example for what the transformation is actually doing.) If all your clustering variables are already on the same natural scale (e.g. a set of Likert items all scored 1–5), standardizing is optional rather than mandatory, but it rarely hurts.

Hierarchical Cluster Analysis: exploratory, unknown cluster count

Go to Analyze > Classify > Hierarchical Cluster. Move your (standardized) clustering variables into the Variable(s) box. Under Method, choose a clustering method and a distance measure — Ward’s method with squared Euclidean distance is the most commonly used combination for continuous data, because Ward’s method minimizes within-cluster variance at each step and tends to produce clusters of relatively even size. Other available linkage methods include between-groups linkage, within-groups linkage, nearest neighbor (single linkage), furthest neighbor (complete linkage), centroid clustering, and median clustering — each merges clusters using a different rule for “distance between clusters,” and they can produce noticeably different trees on the same data.

Under Plots, check Dendrogram. Under Statistics, check Agglomeration schedule if you want the numeric merge history alongside the picture. Click Continue, then OK.

Reading the output

  • Agglomeration Schedule lists every merge step in order: which two clusters combined, at what “Coefficients” value (the distance at which they merged), and at which stage each of the original clusters last appeared. Reading down the Coefficients column, a large jump between two consecutive stages signals that the merge at that step combined two clusters that were relatively far apart — a common rule of thumb is to stop just before the first big jump, since everything merged after that point is joining dissimilar groups.
  • Dendrogram shows the same merge sequence as a tree, rescaled to a 0–25 axis. To pick a cluster count visually, imagine a vertical line moved from right to left; the number of horizontal lines it crosses is the number of clusters at that point. Look for a point where you can draw that line through a long horizontal stretch with no merges — that’s the same “big jump” signal as the agglomeration schedule, just visual instead of numeric.
  • Icicle plot (on by default unless you turn it off) is a compact alternative view of the same merge history, read top-to-bottom instead of left-to-right; most users rely on the dendrogram instead once they know to look for it.

Once you’ve settled on a cluster count from the dendrogram, go back into Hierarchical Cluster, open Statistics, check Cluster membership, and specify that number under Single solution (or a range, if you want to compare a few counts side by side). Under Save, check the same option to write a cluster-membership variable into your dataset that you can then use in further analysis, such as comparing cluster means with ANOVA or crosstabs.

K-Means Cluster Analysis: specified cluster count, larger datasets

Go to Analyze > Classify > K-Means Cluster. Move your (standardized) clustering variables into Variables, and enter the Number of Clusters you want — this is a required input, not something the procedure estimates for you. Under Iterate, you can adjust the maximum iterations and convergence criterion (defaults are usually adequate). Under Save, check Cluster membership to write the assigned cluster into your dataset, and optionally Distance from cluster center. Under Options, check ANOVA table and Cluster information for each case if you want that output. Click OK.

K-means works by starting from a set of initial cluster centers, assigning every case to its nearest center, recalculating the centers as the mean of the cases now assigned to them, and repeating until assignments stop changing (or the iteration limit is hit). Because it only has to compute distance from each case to a small number of centers, rather than every case to every other case, it scales to far larger sample sizes than hierarchical clustering, which requires computing and storing the full case-by-case distance matrix.

Reading the output

  • Initial Cluster Centers shows the starting values SPSS picked (widely spaced cases from the data, by default) for each cluster on each variable.
  • Iteration History shows how much the cluster centers moved at each iteration; it should shrink toward a small number and stop, confirming the solution converged rather than hitting the iteration cap.
  • Final Cluster Centers is the table you’ll actually interpret and typically report: the mean of each clustering variable within each final cluster. This is what you read to describe what distinguishes the clusters — e.g. “Cluster 1 scores higher on X and lower on Y.”
  • Distances between Final Cluster Centers tells you how separated the clusters are from each other; centers that are very close together suggest the clusters may not be very distinct.
  • ANOVA table reports an F-test for each clustering variable, but SPSS’s own documentation flags this as descriptive only: because the clusters were formed specifically to maximize differences between groups on these same variables, the F-tests are not valid significance tests in the usual sense and shouldn’t be reported as if they were — use them only to see which variables contributed most to separating the clusters, not to claim a significant result.
  • Number of Cases in each Cluster is worth checking on its own: a solution with one huge cluster and several tiny ones is often a sign the chosen k doesn’t fit the data well, even if the procedure ran without error.

Choosing between them

Hierarchical Cluster K-Means Cluster
Cluster count Not specified in advance — decided after looking at the dendrogram Specified before running the procedure
Best suited to Exploratory work, smaller samples Confirmatory work, larger samples
Practical dataset size Struggles well before a few thousand cases (full distance matrix) Handles far larger samples comfortably
Reproducibility across runs Deterministic for a given method/distance combination Can vary slightly run to run depending on initial center selection, unless centers are fixed
Typical use First pass to discover how many natural groups exist Production segmentation once k is known or decided on other grounds

A common combined workflow: run hierarchical clustering on a representative subsample (or the full sample, if it’s small enough) to get a sense of how many clusters the data actually supports, using the dendrogram and agglomeration schedule as described above. Then run K-means on the full dataset specifying that number of clusters. This gets you the exploratory benefit of hierarchical clustering without asking it to handle a sample size it isn’t built for.

SPSS also offers a third procedure, TwoStep Cluster (also under Analyze > Classify), which can handle a mix of categorical and continuous variables and can suggest a cluster count automatically. It’s a reasonable option when your variables aren’t all continuous, but it’s a different procedure with its own output and isn’t a drop-in replacement for either method described here.

FAQ

Is cluster analysis the same thing as cluster sampling?

No — they share a name but are unrelated. Cluster sampling is a data-collection design where you randomly select whole pre-existing groups (e.g. schools or clinics) rather than individuals. Cluster analysis, covered on this page, is a data-analysis technique applied after data is already collected, used to group cases (or variables) by similarity. See cluster sampling for the sampling-design concept.

How many clusters should I use?

There’s no single automatic answer in either procedure — hierarchical clustering gives you the dendrogram and agglomeration schedule to judge visually and numerically where a natural break occurs; K-means requires you to decide beforehand, often informed by a prior hierarchical run, a theoretical expectation about how many groups should exist, or by comparing solutions at a few candidate values of k and checking which one produces clusters that are both reasonably sized and substantively interpretable.

Do I need to standardize my variables before clustering?

If your clustering variables are on meaningfully different scales, yes — otherwise the variable with the largest numeric range will dominate the distance calculation regardless of its actual importance. Use Descriptives with “Save standardized values as variables” checked, then cluster on the resulting Z-variables.

Why does my K-means ANOVA table show significant results for every variable?

Because K-means selects cluster assignments specifically to maximize between-cluster differences on the variables you clustered on, the F-tests in that ANOVA table are inflated by construction and aren’t valid hypothesis tests — SPSS’s documentation itself flags this. Use the table descriptively, to see which variables separate the clusters most, not as evidence of a “real” effect.

Can I run K-means on categorical variables?

Standard K-means in SPSS is built for continuous (interval/ratio) variables, since it clusters on Euclidean distance between means. For a mix of categorical and continuous variables, SPSS’s TwoStep Cluster procedure is the better fit.

Related reading

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Regulatory Radar

Stop finding out after the fact

$29/month, cancel anytime. Daily digest updates from our analysis, a dashboard holding the same items, and a cited assistant for everything they raise.

  • Federal Register, Federal Register+, Grants.gov, Regulations.gov, NSF News, UKRI, plus CASRAI’s own published content.
  • 44,322 indexed passages, and every answer cites the ones it drew on.