1.3 - Chi-square test
Learn how observed category counts are compared with expected frequencies, calculate chi-square and degrees of freedom, and interpret an association without assuming causation.
When chi-square is appropriate
Chi-square analyses frequencies in categories rather than ranked individual scores.
A researcher randomly assigns separate people to receive a reminder or no reminder, then records whether each attends a study session. Reminder condition and attendance are nominal categories. The question is whether attendance proportions differ between the conditions, equivalently whether condition and attendance are associated. A contingency table cross-classifies the two variables. Each person enters exactly one cell.
Observed and expected frequencies
An observed frequency, O, is the actual count in a category or cell. An expected frequency, E, is the count predicted by the stated null model.
Use counts, not percentages or group means. Observations must be independent: putting the same people in both conditions and counting their two answers as separate observations violates the ordinary contingency-table test. Categories must be mutually exclusive, so someone cannot be counted as both attending and absent on the same occasion.
Expected counts also matter. For the small 2×2 tables taught here, check that every E is at least 5 before relying on the usual chi-square approximation. This is a condition on expected, not observed, frequencies. For larger tables, conventions can allow a limited number of E values below 5, but sparse tables need suitable specialist or exact support; do not apply a memorised threshold without checking the analysis. Chi-square does not require normally distributed scores.
A one-variable goodness-of-fit test compares category counts with a specified distribution, such as a predicted 1:1 preference split. It is distinct from testing association between two categorical variables. The null model determines E: equal expected counts are justified only when that model predicts equal proportions.
Calculate the null-model frequencies
For an association test, expected counts preserve the row and column totals while representing no association between the variables.
This original reminder study has the following observed counts:
| Condition | Attended | Absent | Row total |
|---|---|---|---|
| Reminder | 26 | 14 | 40 |
| No reminder | 14 | 26 | 40 |
| Column total | 40 | 40 | 80 |
Under the null hypothesis, reminder condition and attendance are independent. Overall, half of the 80 people attended, so each row of 40 is expected to contain 20 attendees and 20 absentees. More generally:
The reminder/attended cell has . Each of the other cells also has . Expected values can be decimals: an expectation of 12.5 is valid even though an observed count must be a whole number. Expected row and column totals should match the observed margins; this is a useful check.
Do not assume all cells have the same E in every table. If a row contains 30 people, an attendance column totals 25 and the grand total is 60, that cell has . The supplied formula handles unequal row and column totals automatically.
For a one-variable equal preference split, use . For another specified ratio, multiply the total by each null-model proportion. For example, a 3:1 prediction among 40 choices expects 30 and 10, rather than 20 and 20.
Sum every cell's contribution
Chi-square adds the squared discrepancy between O and E, scaled by E, across all the cells.
The sigma symbol means sum the contribution from every included cell.
Apply the supplied formula to the reminder table:
| Cell | O | E | ||
|---|---|---|---|---|
| Reminder, attended | 26 | 20 | 6 | |
| Reminder, absent | 14 | 20 | −6 | |
| No reminder, attended | 14 | 20 | −6 | |
| No reminder, absent | 26 | 20 | 6 |
Therefore . Negative discrepancies become positive when squared; contributions cannot cancel. Include all four cells, rather than calculating only the attended column. Divide by E, not O. The statistic is dimensionless: do not label the final 7.2 as people or percent.
Retain unrounded intermediate values unless the task explicitly requests rounding at every step. For instance, four contributions of total , giving 6.67 to two decimal places if rounded only at the end; rounding each contribution to 1.67 first would give 6.68. The requested precision determines the method. OCR has supplied tasks requesting two decimal places for all calculations, so always read that instruction rather than imposing one convention on every task.
The ordinary formula shown here has no continuity correction. Do not add a correction merely because another subject or software package uses one; a task's supplied equation determines the calculation requested.
Use the data categories for degrees of freedom
Degrees of freedom identify the chi-square reference distribution needed for the table lookup.
For a two-variable contingency table:
Here r is the number of data rows and c the number of data columns. Exclude totals and headings.
The reminder table has two conditions and two outcomes, so . It does not have because there are two groups, or because there are 80 people. With the row and column totals fixed, knowing one cell in a 2×2 table determines the other three, which explains the one free value.
A table with three response categories and two conditions has . Algebra can also recover a missing table dimension: if and , then , so and .
For a goodness-of-fit test with k categories and fully specified probabilities, . Estimating additional parameters from the data can change that rule, so do not apply the contingency-table formula to a one-row preference test.
Interpret the upper-tail decision
A larger chi-square indicates a greater discrepancy from the null model, so significance uses the upper tail of its reference distribution.
This supplied critical-value extract uses df and the upper-tail significance level:
| df | ||
|---|---|---|
| 1 | 3.841 | 6.635 |
| 2 | 5.991 | 9.210 |
For the reminder example, . At the 5% level, , so reject the null hypothesis of no association between reminder condition and attendance. It also exceeds 6.635, the 1% critical value. The rule is observed chi-square greater than or equal to critical chi-square, including equality. These are upper-tail chi-square probabilities; do not halve the threshold because a verbal hypothesis mentions a direction.
Inspect the observed proportions to describe the association: 26/40, or 65%, attended after a reminder, compared with 14/40, or 35%, without one. Chi-square itself has no positive or negative sign telling us which group attended more. Statistical significance does not measure the importance of this difference. Causal interpretation comes from the design and control of other influences, not the test alone; an observational association could reflect a third variable.
If the observed statistic is below its critical value, fail to reject the null. This means the evidence is insufficient at the chosen level, rather than proving no association. Report the test, observed value, df, threshold and contextual conclusion. The significance probability describes outcomes at least this extreme under the null model; it is not the probability that the null is true.