SPSS command: SPSS TWOSTEP CLUSTER

TwoStep cluster analysis in your browser

TwoStep cluster finds natural groups in data that mixes continuous and categorical variables, and can choose the number of clusters for you.

Free · No account · Files stay on your device · Updated 18 October 2026

What it tells you

Crosstabs runs the SPSS TWOSTEP CLUSTER procedure on your device: CF-tree pre-clustering, then agglomerative clustering with the log-likelihood or Euclidean distance, with the cluster count picked by BIC or AIC.

  • How many clusters the data supports, from the BIC or AIC curve and the ratio of distance measures.
  • How well separated the clusters are, as an average silhouette from −1 to 1 rated poor, fair or good.
  • Each cluster's size and profile: means and standard deviations of continuous variables and category counts of categorical ones.
  • Which variables drive the clustering, through predictor importance based on chi-square and F tests across clusters.

When to use it

Use it when

  • Segmenting customers on a mix of numbers (age, spend) and categories (channel, region) without converting categories to dummies.
  • You do not know how many segments to expect and want an information-criterion answer as a starting point.
  • Files too large for a full case-by-case distance matrix, since the CF tree summarises cases before clustering.

Use something else when

  • Only continuous variables on comparable scales and a known number of groups: k-means is simpler and its centers are easier to report.
  • A small file where you want to see every merge: hierarchical clustering shows the full agglomeration schedule and dendrogram.
  • You already have a known group variable and want to predict it: use discriminant analysis or a decision tree.

How to run it in Crosstabs

  1. 01

    Choose TwoStep cluster

    In Statistics mode, open the Classify group and pick TwoStep cluster (TWOSTEP CLUSTER).

  2. 02

    Split variables by type

    Tick numeric variables under Continuous variables and nominal ones under Categorical variables; a variable can sit in only one list.

  3. 03

    Pick distance and criterion

    Keep the Log-likelihood distance measure for mixed data (Euclidean works only with continuous variables), and choose Schwarz's Bayesian Criterion (BIC) or Akaike's Information Criterion (AIC).

  4. 04

    Set the number of clusters

    Leave Number of clusters on Determine automatically with a Maximum (15 by default), or switch to Specify fixed and enter the number.

  5. 05

    Standardize and run

    Keep Standardize continuous variables ticked so variables in different units count equally, then run. A workspace weight is not applied: TwoStep clusters individual cases.

Worked example

Computed by the Crosstabs engine from the synthetic data below when this page was built — not typed in.

Try with example data

Data

150 synthetic shoppers generated as three segments of 50: age, monthly spend and preferred channel (Online, Store, Mixed), where each segment has a main channel that about four in five of its members use. Values carry normal noise and a fixed seed. TwoStep runs with the log-likelihood distance, standardized continuous variables and BIC, choosing the number of clusters automatically (maximum 15).

Auto-Clustering
Number of ClustersBICBIC ChangeRatio of BIC ChangesRatio of Distance Measures
1557.639———
2352.307−205.3321.0001.463
3221.431−130.8760.6374.965
4219.079−2.3520.0111.165
5221.3102.231−0.0111.564
6233.57912.270−0.0602.332

First 6 of 15 rows. Changes are from the previous number of clusters; ratios are relative to the two-cluster solution.

Cluster Distribution
ClusterN% of Combined
16442.7
25033.3
33624.0
Centroids
Variable1: Mean2: Mean3: MeanCombined: Mean
age45.229.562.644.1
spend171.3112.1117.1138.5
channel by cluster
ClusterMixed (%)Online (%)Store (%)
164 (100.0)0 (0.0)0 (0.0)
20 (0.0)50 (100.0)0 (0.0)
30 (0.0)0 (0.0)36 (100.0)

How to read it

TwoStep chose 3 clusters by BIC from 150 cases, with sizes 64, 50, 36. The silhouette measure of cohesion and separation is 0.575, which the panel rates as good cluster quality, and channel is the most important predictor (importance 1.000). Every cluster is channel-pure, even though a fifth of each simulated segment uses another channel: in the log-likelihood distance a categorical variable adds an entropy term that is zero for a pure cluster, so one categorical field can dominate. The centroids then show how age and spend differ within that split. With 150 records the pre-clustering kept 150 sub-clusters, so the hierarchical step is exact.

Output tables explained

Model Summary
The silhouette measure of cohesion and separation on a −1 to 1 bar: below 0.2 poor, 0.2–0.5 fair, above 0.5 good.
Auto-Clustering
BIC or AIC for each number of clusters, its change, the ratio of changes and the ratio of distance measures. The chosen solution is where the criterion stops improving and the distance ratio peaks.
Cluster Distribution
N per cluster as a percentage of clustered cases and of the total, plus excluded cases (any missing value excludes a case).
Centroids
Mean and standard deviation of each continuous variable in every cluster and combined, on the original scale. Each categorical variable gets its own table of counts and percentages by cluster.
Predictor Importance
−log10 p of a chi-square (categorical) or F (continuous) test across clusters, scaled so the most important variable is 1.

Assumptions and notes

  • The log-likelihood distance treats continuous variables as normal and categorical ones as multinomial, all independent within a cluster; the method is fairly robust to moderate violations.
  • Cases with any missing value are excluded listwise.
  • Once the CF tree must raise its threshold (roughly a few hundred distinct records or more), results depend on case order, as in SPSS; below that the pre-clustering is lossless.
  • Predictor importance p values are descriptive: the clusters were built to differ.

How the results are validated

TwoStep is checked against an independent NumPy implementation of the TWOSTEP CLUSTER chapter of the IBM SPSS Statistics Algorithms manual: on 120 mixed continuous and categorical records, BIC and AIC for every cluster count and the distance-measure ratios agree within 1e-9, and the chosen number of clusters and every case assignment are identical (BIC, AIC and a fixed four-cluster solution, plus a continuous-only Euclidean set of 90 records). A 1,500-case test confirms the CF tree stays within 512 sub-clusters and repeats exactly; silhouette and predictor importance match an independent implementation of the Cluster Evaluation formulas. Validation evidence

Questions

How does TwoStep decide the number of clusters?

It first finds the smallest number of clusters where the BIC (or AIC) change has fallen to a small fraction of the first change, then refines that guess with the ratio of distance measures between successive merges. You can override it with Specify fixed.

Why does one categorical variable dominate my clusters?

In the log-likelihood distance a categorical variable contributes an entropy term that drops to zero when a cluster is pure, so clusters often align with a strong categorical field. Check Predictor Importance, and try clustering without that variable to see the structure in the rest.

Should I standardize continuous variables?

Usually yes, and it is on by default. Without it a variable measured in dollars would outweigh one measured on a 1–5 scale. Centroids are still reported in the original units.

Will I get the same clusters as SPSS?

For files small enough that every distinct case gets its own sub-cluster, the hierarchical step is exact. In larger files the CF tree raises its threshold, results then depend on case order, and they can differ from SPSS's tree.

Can I use a weight variable?

No. TwoStep groups individual cases, so a workspace weight is shown as not applied rather than silently used.

Run TwoStep Cluster on your own data

Open a .sav, CSV or Excel file. Everything runs in your browser; the file never leaves your device.

Open the workspace

SPSS is a trademark of IBM Corp. Crosstabs is not affiliated with or endorsed by IBM.