Open navigation
OpenOpen workspace

Segmentation

Latent class analysis

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

简体中文版

Lowest BIC

k = 3

Classes of 46.3%, 33.7%, 20.1%

97.1% match the planted classes · entropy R² 0.92

Synthetic shopper sample · 900 respondents · same data as “Use sample data”

Latent class analysis (LCA) finds segments in survey data by assuming each respondent belongs to one of k unobserved classes, each with its own pattern of answers. Unlike k-means it works directly on categorical answers (store used, yes/no, rating scales) and numeric ones, handles blank answers, and gives every respondent a probability of belonging to each class. This tool fits 1 to 8 classes, compares them by BIC, AIC and entropy, profiles the classes and exports memberships plus a typing tool — free, with no account, and the file is never uploaded.

Run latent class analysis online

Open a CSV, Excel, SPSS, Stata, SAS or JSON file (or the synthetic shopper sample), tick the indicator questions and set each as categorical, ordinal or continuous, choose a range of k and run. Each model is estimated by maximum likelihood with the EM algorithm from 10 seeded random starts by default, in a background worker so the page stays responsive. The same file, settings and seed always give the same classes.

CSV, Excel, SPSS, Stata, SAS, R, Parquet, SQLite or JSON. The file is read in this browser tab and never uploaded. For Triple-S, select the .sss or .xml metadata file and its data file together.

Choosing the number of classes

In theory adding classes always raises the log-likelihood (with random starts a fit can still land on a local maximum), so models are compared with information criteria that charge for each extra parameter. BIC is the usual first guide for latent class models and the recommendation uses it: the lowest BIC among identified models whose smallest class holds at least 5% of respondents. AIC tends to keep more classes; CAIC is stricter than BIC; the sample-size-adjusted BIC sits between them.

Entropy R² (0 to 1) says how cleanly respondents are assigned: above about 0.8 the modal classes are reliable enough to use as a segment column. Then read the profiles — a model whose classes your team can name and act on is worth more than a small BIC gain. If you have only rating scales and want distance-based clusters, compare with the k-means segment builder.

The method

Formula

Definition

P(xᵢ) = Σₖ πₖ Πⱼ fⱼ(xᵢⱼ | k); P(k | xᵢ) = πₖ Πⱼ fⱼ(xᵢⱼ | k) / P(xᵢ); BIC = −2 log L + p ln n

where

πₖ
share of class k (the class prior), summing to 1
fⱼ(x | k)
the answer distribution of indicator j in class k: a category probability for categorical and ordinal indicators, a normal density with class mean and variance for continuous ones (variances are kept above 1% of the indicator's total variance so no class can collapse onto a single value)
Πⱼ
product over the indicators the respondent answered; blank answers are skipped (missing at random)
P(k | xᵢ)
posterior probability that respondent i belongs to class k; the modal class is the largest
p
free parameters: (k − 1) + k(Cⱼ − 1) per categorical indicator with Cⱼ categories + 2k per continuous indicator
Entropy R²
1 − Σᵢ Σₖ −P(k | xᵢ) ln P(k | xᵢ) / (n ln k): 1 means every respondent is assigned with certainty
Index
class value ÷ total × 100 for a category share or a mean; ≥ 110 is highlighted as high and ≤ 90 as low

Worked example

Worked example

The synthetic shopper sample has 900 respondents and seven indicators: main store, coupon use, organic buying and shopping frequency (categorical), brand loyalty and price sensitivity (1–5, treated as categories) and monthly grocery spend (continuous). Each respondent was generated from one of three planted classes; about 4% of answers are blank. Fitting k = 1 to 6 gives BICs of 23102 (k = 1), 22076 (k = 2), 21585 (k = 3), 21674 (k = 4), 21762 (k = 5), 21858 (k = 6).

The lowest BIC is k = 3, with class shares of 46.3%, 33.7%, 20.1% and an entropy R² of 0.916. The modal classes match the planted ones for 97.1% of respondents (classes 1–3 correspond to Deal seekers, Premium loyalists, Convenience shoppers, matched one to one). Class 1 names “Discount store” as its main store 58% of the time against 32% overall, and its mean monthly grocery spend is 424 versus 466 — a deal-seeking class.

Larger models fit only slightly better and are penalized by BIC; their extra classes also tend to be reached by fewer random starts, a sign that EM is finding unstable local solutions.

Using it well

When to use it

Use it when

  • Use: Segmenting on nominal or mixed answers — channels, brands used, yes/no behaviours, rating scales and spend together.
  • Use: You want each respondent's probability of belonging to every class, not only a hard assignment.
  • Use: You need a typing tool: the parameter export classifies new respondents from their answers.

Not the right tool when

  • Avoid: Fewer than a few hundred respondents or many sparse categories — models with many classes will not be identified.
  • Avoid: Indicators that are strongly related within a class (two near-duplicate questions); local independence is assumed.
  • Avoid: Very large files: runs here are limited to 20,000 rows and 200,000 answers (rows × indicators).

How to interpret it

Rule of thumb

Judge a model on BIC together with entropy, the smallest class share, whether the best log-likelihood was reached from more than one start, and whether the item-response profiles tell a story. Classes summarize answer patterns; they are not natural types of people, and modal assignments carry classification error — keep the posterior probabilities when you analyse the classes further.

Questions

Frequently asked questions

How is latent class analysis different from k-means?

K-means groups respondents by distance on numeric variables and assigns each respondent to exactly one cluster. Latent class analysis is a statistical model: it works with categorical, ordinal and numeric answers, handles missing answers in the likelihood, compares solutions with information criteria such as BIC, and gives each respondent a probability of belonging to every class.

How are ordinal questions handled?

Ordinal indicators such as 1–5 ratings are modelled as unordered categories, which estimates a free probability for every scale point in each class. This uses more parameters than an ordered model but makes no assumption about the spacing of the scale. You can instead set a long scale (for example 0–10) as continuous.

What about blank answers and weights?

Blank answers are skipped in the likelihood (missing at random), so a respondent who answered any indicator is classified; only respondents with no answered indicator are left out. An optional weight column enters the estimation as a pseudo-likelihood with weights rescaled to a mean of 1; information criteria use the unweighted number of respondents.

Why does the tool use several random starts?

The EM algorithm can stop at a local maximum of the likelihood. Each model is fitted from several seeded random starts: every start runs a short EM, the most promising ones are run to convergence, and the best log-likelihood is kept. The comparison table reports how many of the starts run to convergence reached it (for example 3/4); if only one did, re-run with more starts or another seed before trusting that model.

How do I classify new respondents?

Export the typing-tool parameters: class shares, the probability of each answer within each class, and class means and variances for continuous indicators. A new respondent's class probability is proportional to the class share times the product of the probabilities of their answers. The in-page classifier does the same calculation as you enter answers.

Is my data uploaded anywhere?

No. The file is read and the models are estimated in your browser tab (in a Web Worker), and the exports are generated there too. Nothing is sent to a server and no account is needed.