Start studying
Module 9 · Sampling and Inference Module contents
Module 9  ·  Card 15 / 16intermediate

Chi-Square Test

A chi-square test checks whether 2 categorical variables are related, using the counts in a table.

It compares the observed count in each cell with the count expected if the variables were unrelated.

For example, it can test whether the payment method chosen differs between mobile and desktop customers.

Large gaps between observed and expected counts give a large chi-square statistic and a small p-value.

Expected counts below about 5 in many cells make the result unreliable, so small categories are often merged.

Learn in depth ↓
Module 09 · Sampling and Inference · 16 concepts
In depth  /  15 lines

Chi-Square Test, in more detail

The chi-square test handles questions about categories, where the data is counts rather than measurements.

Typical questions are whether the choice of plan depends on region, or whether a die is fair.

It works on a contingency table, which counts how often each combination of categories occurs.

Expected counts come from the row and column totals, assuming the 2 variables are unrelated.

For each cell, the expected count is the row total times the column total, divided by the grand total.

Each cell then contributes the squared gap between observed and expected, divided by the expected count.

The sum of those parts is the chi-square statistic, and larger values mean larger departures from independence.

The degrees of freedom are the number of rows minus 1, times the number of columns minus 1.

A goodness of fit version compares one set of counts with a fixed expectation, such as equal sales on each weekday.

The test needs counts of independent units, not percentages or repeated answers from the same people.

Small expected counts make it unreliable, and Fisher's exact test is a common alternative for small tables.

A significant result says the variables are related, not how strongly or in which cells.

Comparing observed and expected counts cell by cell shows where the difference comes from.

In practice, chi-square tests are common in survey analysis and in comparing conversion counts between groups.

The usual mistake is running the test on percentages instead of counts, which gives a meaningless result.

Want the full technical article? Wikipedia ↗
Test yourself

One question on this card. Every option explains itself once you pick, right or wrong.

Question 1
An analyst has a table counting payment method by device, mobile or desktop. Which test checks whether the 2 are related?
Sampling and Inference

16 concepts in this module, then a graded test with every answer explained.

Study this module →
↑↓ move↵ openesc close