Categorical Data: The Chi-Square Test
The chi-square test checks whether two categories are related more than chance would predict — a plain-language guide to analysing categorical data.
Statistics for Everyday Life · Lesson 2
The chi-square test checks whether two categories are related more than chance would predict — a plain-language guide to analysing categorical data.
Not all data are numbers you average. Much of the world comes in categories: yes/no, passed/failed, which product someone chose, whether a treatment group recovered. When you want to know whether two such categories are related, the t-test won't do — you need a different tool. The most common is the chi-square test.
Categorical data sort things into groups rather than measuring an amount. A typical question: is there a relationship between two categories — say, between taking a medication (yes/no) and recovering (yes/no)? You arrange the counts in a table (a contingency table) and ask whether the pattern is more lopsided than chance would produce.
The chi-square test compares the counts you actually observed with the counts you'd expect if the two categories were completely unrelated (independent). If observed and expected are close, there's little evidence of a relationship; if they diverge a lot, that suggests an association.
The test essentially asks whether the two variables are independent (unrelated) or associated (the value of one tells you something about the other). As always, an association is not proof of causation — the chi-square test finds patterns, not causes.
A shop wants to know whether customers who saw a display (yes/no) were more likely to buy a product (yes/no). It tabulates the four counts. If buyers are spread across 'saw display' and 'didn't' roughly as expected under no relationship, chi-square finds little; if buyers cluster strongly among those who saw the display, beyond what chance would give, the test flags an association worth investigating.
Chi-square answers 'is there an association?' — not 'how strong?' or 'why?'. A significant chi-square in a huge dataset may reflect a tiny, unimportant association; and a found association could be driven by a lurking third factor (perhaps people who seek out the display were already keen to buy). The test detects a pattern; interpreting it still needs judgment.
The chi-square test was introduced by the statistician Karl Pearson around 1900, and it became one of the foundational tools of modern statistics. Its power was to give researchers a rigorous way to ask whether observed frequencies — in biology, medicine, social science, and beyond — differed from what chance alone would produce. Before such tests, judging whether a pattern in categorical counts was 'real' relied on intuition; Pearson's method made it systematic. More than a century later, chi-square remains one of the most widely used tests precisely because so many real questions are categorical: did more people in one group respond, choose, survive, or fail than you'd expect if the groups were the same? It endures because that question is everywhere.
Think of two yes/no categories you're curious about (e.g., 'exercised today' and 'slept well'). Sketch the four-cell table. What pattern of counts would suggest an association versus none?
Think Like a Maester: For questions about categories, compare what you observed with what pure chance would expect — the gap is where the story lives.
The chi-square test analyses categorical data, comparing the counts you observed with those expected if two categories were unrelated; a large gap suggests an association. Introduced by Karl Pearson around 1900, it made judging categorical patterns systematic and remains among the most-used tests because so many real questions are categorical. Like all such tools, it detects association, not causation or strength, so its results still require careful interpretation.
Mark this lesson complete to track your progress.