Open navigation
OpenOpen workspace

Survey segmentation

K-means vs latent class analysis for survey segmentation

Use k-means when the segmentation variables are numeric (scores, ratings treated as interval, spend) and complete; it is fast, simple and picks the number of segments with a measure such as the silhouette. Use latent class analysis when the questions are categorical or mixed, when answers are missing, or when you want each respondent's probability of belonging to each segment; it is a statistical model, so you choose the number of classes with BIC. On typical survey questionnaires, which are mostly categorical, latent class analysis is usually the better fit.

Published by crosstabs.com · Last updated ·
How results are checkedNamed statistical review pending. Selected automated reference cases are published on the validation page.

How k-means works

K-means standardises the variables, places k segment centres, assigns each respondent to the nearest centre, moves each centre to the mean of its members, and repeats until nothing changes. The result is a hard assignment that minimises within-segment squared distance. Because everything rests on distances, the variables must be numeric and on comparable scales, and every respondent needs a value on every variable. Different starting centres can give different solutions, so good implementations start deterministically or try several starts.

How latent class analysis works

Latent class analysis assumes each respondent belongs to one of k unobserved classes and that, within a class, answers to the indicators are independent. It estimates each class's size and its answer probabilities (or, for numeric indicators, means and variances) by maximum likelihood with the EM algorithm, then gives every respondent a posterior probability for each class. Because it is a likelihood model, solutions with different numbers of classes can be compared with information criteria, and categorical, ordinal and numeric indicators can be mixed.

The method

Formula

Definition

k-means: minimise Σi ‖xi − cs(i)‖² · silhouette s(i) = (bi − ai) / max(ai, bi)
latent class: P(yi) = Σc πc Πj P(yij | c) · BIC = −2 log L + q ln n

where

x_i, c_s(i)
respondent i's standardised values and the centre of the segment it is assigned to
a_i, b_i
mean distance from i to its own segment and to the nearest other segment
π_c
share of class c; P(y_ij | c) is the probability (or density) of answer j given the class
q, n
number of free parameters and respondents; the lowest BIC balances fit against complexity

Worked example

Worked example

Sample data: the synthetic shopper survey that the latent class analysis tool loads with “Use sample data”: 900 generated respondents built from three planted classes (deal seekers, premium loyalists and convenience shoppers), so we know the right answer. Seven segmentation questions are asked: main store, coupon use, organic buying and shopping frequency (categorical), brand loyalty and price sensitivity (1–5) and monthly spend (numeric). About 4% of each answer is blank.

K-means. The segment builder clusters numeric variables only, so it uses the three numeric questions (brand loyalty (1–5), price sensitivity (1–5), monthly grocery spend). Rows with any of them blank are dropped, leaving 780 of 900 respondents. The average silhouette is highest for k = 2 (0.411, against 0.348 for k = 3), so that is the recommendation. Forcing k = 3 gives segments of 314, 254, 212 respondents that match the planted classes for 87.2% of the clustered respondents.

Latent class analysis. The latent class model uses all seven questions and all 900 respondents, skipping blanks in the likelihood. BIC falls from 23102.1 (one class) to 22075.8 (two) and 21585.2 (three), then rises again from four classes, so the recommendation is 3 classes. Each respondent's most likely class matches the planted class for 97.1% of the sample, and the relative entropy of 0.92 says most respondents are classified with high certainty.

The comparison is not a contest on equal terms, and that is the point: with mixed categorical and numeric questions and scattered blanks, latent class analysis can use everything the survey collected, while k-means sees only the numeric part of it and a smaller base.

Using it well

When to use it

Use it when

  • Use: K-means: a handful of complete numeric variables, such as factor scores, ratings or spend, and a need for quick, easily explained segments.
  • Use: Latent class: categorical or mixed questions (pick-one, yes/no, ratings, spend) or blanks you do not want to impute.
  • Use: Latent class: you need classification probabilities, for example to flag respondents who sit between segments.

Not the right tool when

  • Avoid: K-means on dummy-coded categorical questions: the distances, and therefore the segments, depend on arbitrary coding.
  • Avoid: Either method on unstandardised variables with very different ranges or on dozens of redundant items; reduce or select variables first.
  • Avoid: Either method as proof that segments exist: both return the number of groups you ask for.

How to interpret it

Rule of thumb

Pick the number of segments with the method's own criterion (silhouette for k-means, BIC for latent class), reject solutions with tiny segments, and keep the one whose profiles a marketer can name and act on.

Next step: segment your own respondents

The free segment builder runs deterministic k-means on 2 to 20 numeric variables, compares k = 2 to 8 by average silhouette, recommends only solutions whose smallest segment holds at least 5% of respondents (when one exists), and profiles each segment against the total with index scores.

The free latent class analysis tool fits 1 to 8 classes on categorical, ordinal and numeric indicators with several seeded random starts, compares them by BIC and other criteria, reports relative entropy and class profiles, and adds each respondent's class and probabilities to the data. Both run in your browser with no account.

Questions

Frequently asked questions

What is the main difference between k-means and latent class analysis?

K-means assigns each respondent to the nearest segment centre in a space of numeric variables and minimises within-segment distance. Latent class analysis is a statistical model: it assumes the population is a mixture of unobserved classes, estimates each class's answer probabilities (or means), and gives every respondent a probability of belonging to each class.

Can k-means use categorical survey questions?

Only after recoding them into numbers, usually 0/1 dummies, which makes the distance between categories an arbitrary choice and lets multi-category questions dominate. Latent class analysis models categorical answers directly, which is why it is the usual choice when segmentation questions are yes/no, pick-one or rating items.

How do I choose the number of segments?

For k-means, compare solutions with a quality measure such as the average silhouette and check that no segment is tiny. For latent class models, compare information criteria such as BIC (lower is better) across class counts and check class sizes and classification certainty. In both cases the final choice also needs segments that make sense and can be acted on.

What happens to respondents with missing answers?

Standard k-means needs a complete set of values, so respondents with any blank clustering variable are dropped or must be imputed. Latent class estimation can skip a missing indicator in the likelihood and classify the respondent from the answers they gave, under a missing-at-random assumption.

Are segments from either method real groups?

Not necessarily. Both methods always return the number of segments you ask for, even from data with no group structure. Validate segments by profiling them on variables not used to build them, checking stability across random starts or split halves, and asking whether the business would treat them differently.

Sources and next steps

References & further reading

  1. [1]MacQueen, J. (1967). Some methods for classification and analysis of multivariate observations. Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability, 1, 281–297.
  2. [2]Rousseeuw, P. J. (1987). Silhouettes: A graphical aid to the interpretation and validation of cluster analysis. Journal of Computational and Applied Mathematics, 20, 53–65.
  3. [3]Magidson, J., & Vermunt, J. K. (2002). Latent class models for clustering: A comparison with K-means. Canadian Journal of Marketing Research, 20, 37–44.
  4. [4]Nylund, K. L., Asparouhov, T., & Muthén, B. O. (2007). Deciding on the number of classes in latent class analysis and growth mixture modeling: A Monte Carlo simulation study. Structural Equation Modeling, 14(4), 535–569.

Try it on your own data — free, no signup

Upload a CSV, Excel, SPSS, Stata, SAS, R, Parquet or JSON file. Everything runs in your browser; your file never leaves your device.

Open the workspace →

← All calculators & guides