TwoStep cluster analysis
Finds natural groupings in data that mix categorical and continuous variables, and can choose the number of clusters itself using BIC or AIC.
Menu: Analyze → Classify → TwoStep Cluster…
When should I use it?
- Segment customers by region (categorical), age and spending (continuous).
- Explore how many distinct respondent profiles a survey contains.
What are the assumptions?
- Variables are treated as independent; continuous ones roughly normal within clusters, categorical ones multinomial.
- Continuous variables on different scales should be standardized (on by default).
- Very large files are pre-clustered in one pass, so results can depend on case order — try a random order to check stability.
How do I run it in StatLab?
- Move categorical variables and continuous variables to their lists.
- Keep the log-likelihood distance (Euclidean works for continuous variables only).
- Leave 'Determine automatically' to let BIC (or AIC) and the ratio of distance measures pick the number of clusters, or fix it.
- Save the cluster membership to profile the clusters further.
How do I read the output?
| Output | Meaning |
|---|---|
| Auto-Clustering | BIC/AIC for each number of clusters, its changes, and the ratio of distance measures used to pick the solution. |
| Cluster Distribution | Size of each cluster. |
| Centroids | Mean and standard deviation of each continuous variable per cluster. |
| Frequencies | How the categories of each categorical variable spread over the clusters. |
Worked example
On the practice survey dataset (File → Sample dataset), this command — which the dialog's Paste button also produces — runs the procedure:
PROC glmTwoStep /cat=(group) /cont=(score age) /distance=loglik /n=auto /max=15 /k=3 /criterion=bic /z=YES /save=NO.
Output tables: Auto-Clustering · Cluster Distribution · Centroids · group · Model Summary.
How would I report it in APA style?
A TwoStep cluster analysis (log-likelihood distance) of 2 continuous and 1 categorical variable (N = 150) selected, by BIC and the ratio of distance measures, 3 clusters of 45, 72, 33 cases.
Computed by StatLab's validated procedure code when this page was built. The example only illustrates the steps; choose variables that fit your own research question.
What are common mistakes?
- Treating the automatic number of clusters as a statistical proof — look at the profiles and the BIC curve.
- Using codes of a categorical variable (1, 2, 3) as a continuous variable.