A chi-square test works on a two-way table of counts. The sampling design tells you whether it is a test for homogeneity or for independence. Pick the test, edit the observed counts, and watch the expected counts and conditions update.
Chi-square tests compare observed counts in a two-way table with the counts we would expect if H₀ were true. First decide which test the study design calls for, then compute the expected counts and check the conditions.
Each cell shows its calculation. Red cells have an expected count below 5.
Use a test for homogeneity when you have separate random samples (or treatment groups) and compare the distribution of one categorical variable across them.
Use a test for independence when you have a single random sample and record two categorical variables for each individual, asking whether they are associated.
Homogeneity: H₀ says the distributions are the same in every population. Independence: H₀ says there is no association between the two variables.
Expected count = (row total)(column total) ÷ table total. These are the counts you would expect if the rows all had the same distribution.
Data from random samples or random assignment; each sample at most 10% of its population; and every expected count at least 5.
df depends only on the size of the table. A 3 × 4 table has (3 − 1)(4 − 1) = 6 degrees of freedom.
Choosing and setting up a chi-square test for a two-way table.
| Test for homogeneity | Test for independence | |
|---|---|---|
| Design | Two or more independent samples or treatment groups | One sample |
| Variables | One categorical variable per group | Two categorical variables per individual |
| H₀ | The distribution of the variable is the same for all populations | There is no association between the two variables |
| Hₐ | The distributions are not all the same | There is an association |
| Expected count | (row total)(column total) ÷ grand total | Same |
| df | (rows − 1)(columns − 1) | Same |
| Conditions | Random, 10%, all expected ≥ 5 | Same |
AP-style multiple choice. Pick an answer to see the explanation.
The vocabulary for topic 3.14. Read the list, flip through flashcards, or quiz yourself. For every term in the unit, see the Unit 3 terminology guide.