Chi-square tests are statistical tools used to compare observed data with what we would expect under a hypothesis. They are especially useful for categorical data, such as counts in groups or categories. These tests help scientists decide whether differences in counts are likely due to chance or reflect a real pattern.
You will see chi-square methods in biology, psychology, public health, and social science.
The basic idea is to measure how far observed counts are from expected counts using the chi-square statistic. Larger differences produce a larger test statistic, which can indicate that the null hypothesis does not fit the data well. Common versions include the goodness-of-fit test, the test of independence, and the test of homogeneity.
To use them correctly, students must understand expected counts, degrees of freedom, and the assumptions behind the test.
Understanding Chi-Square Tests
A chi-square result comes from adding contributions from every category or every cell in a table. A cell contributes very little when its observed count is close to its expected count. It contributes more when the gap is large.
Squaring the gap makes positive and negative differences count equally. Dividing by the expected count keeps the comparison fair.
A difference of five people matters much more when ten were expected than when five hundred were expected. This scaling is why raw differences alone are not enough.
In a goodness-of-fit setting, the expected pattern must be chosen before examining the results. It may come from a theory, a past survey, or stated proportions. For example, a genetics model may predict certain trait ratios among offspring.
A fair spinner may predict equal counts for its sections. If the sample does not match perfectly, that is normal. Random samples nearly never match exactly.
The test judges whether the mismatches are unusually large for the sample size. With a very large sample, even a small departure can produce strong evidence. Students should separate statistical evidence from practical importance.
For an independence test, think of the expected count as the number that would appear in one table cell if the two category variables had no connection. Suppose a school records transport method and year group. The row and column totals describe the overall patterns.
Expected counts combine those totals to create a no-connection model. Comparing every actual cell with this model reveals where the relationship is strongest. Cell residuals, meaning observed count minus expected count, help tell the story.
Large positive residuals show combinations occurring more often than expected. Large negative residuals show combinations occurring less often than expected.
Several conditions protect the result from being misleading. Each person or item should be counted once in one category for each variable. The observations should be independent, so one student response should not determine another.
Categories must be clear and nonoverlapping. Expected counts should usually be at least five in most cells. Sparse tables can make the chi-square approximation unreliable.
Combining sensible categories may help, but categories should not be combined merely to force a desired result. The p-value measures how surprising the table would be if the null model were true.
It does not give the probability that the null model is true, and it does not prove cause and effect. A careful conclusion names the variables, describes the pattern, and states the limits of the data.
Key Facts
- Chi-square test statistic:
- Goodness-of-fit expected count: for each category
- Independence expected count in a contingency table:
- Degrees of freedom for goodness-of-fit: , or if parameters are estimated from data
- Degrees of freedom for an r × c table: df = (r - 1)(c - 1)
- A large chi-square value with a small p-value suggests rejecting the null hypothesis
Vocabulary
- Observed count
- The observed count is the actual number recorded in a category from the sample.
- Expected count
- The expected count is the number predicted in a category if the null hypothesis is true.
- Degrees of freedom
- Degrees of freedom tell how many category counts can vary independently once totals or constraints are fixed.
- Null hypothesis
- The null hypothesis is the claim that there is no difference, no association, or that the data follow a stated distribution.
- Contingency table
- A contingency table is a grid of counts showing how two categorical variables are distributed together.
Common Mistakes to Avoid
- Using chi-square with percentages or means instead of counts, because the test is built for frequency data in categories rather than numerical averages.
- Ignoring the expected count condition, because very small expected counts can make the chi-square approximation unreliable and lead to misleading p-values.
- Confusing independence and homogeneity tests, because both use the same statistic but answer different questions about one population versus multiple populations.
- Claiming causation from a significant chi-square result, because the test can show association or mismatch with a model but does not prove one variable causes another.
Practice Questions
- 1 A six-sided die is rolled 60 times. The observed counts are 8, 12, 9, 11, 10, and 10. Test at a basic level whether the die appears fair by finding the expected count for each face and computing .
- 2 A survey records favorite study method for 100 students: visual learners 30 prefer flashcards and 20 prefer notes, auditory learners 10 prefer flashcards and 40 prefer notes. Compute the expected count for each cell and then calculate the statistic for a test of independence.
- 3 A chi-square test of independence gives p = 0.03 for the relationship between exercise level and sleep quality. Explain what this result means and what it does not mean.