Chi-squared test
Studying this course? Keep your progress in one place.
Revised this already? Try an exam question and get it marked free
Key facts
- Chi-squared tests for an association between categories, using frequencies (nominal data) from independent groups.
- χ² = sum of (O - E)² / E, where O is the observed and E the expected frequency.
- E = (row total x column total) / grand total, and each E should be 5 or more.
- df = (rows - 1) x (columns - 1). Significant if the calculated value is equal to or greater than the critical value.
- Use raw frequencies, never percentages, and count each observation once.
When to use chi-squared
Use chi-squared when you have counts in categories (nominal data), the groups are independent, and you are testing for an association or a difference between categories.
Observations often produce tallies: how many men held a door open and how many women did. These are frequencies in categories, which is nominal data. Chi-squared checks whether the pattern of tallies differs from what chance would give.
The conditions are:
- each observation sits in one cell only, so the groups are independent
- you use raw frequencies, not percentages
- every expected frequency is at least 5.
- 1
Do you have counts?
Frequencies in categories, which is nominal data
- 2
Are the groups independent?
Each person or observation sits in one cell only
- 3
Are you testing association or difference?
For example, is age linked to stopping?
- 4
Are expected frequencies 5 or more?
If not, collect more observations
Which data suit a chi-squared test?
Hypotheses and expected frequencies
Write an alternative hypothesis about an association, draw a table of observed frequencies with totals, then calculate each expected frequency as row total times column total divided by grand total.
The alternative hypothesis says there is an association, for example between sex and holding a door open. The null hypothesis says any pattern is due to chance.
Draw a contingency table of observed frequencies and add row, column and grand totals. Then, for each cell:
E = (row total x column total) / grand total
Check that every E is 5 or more. Expected frequencies need not be whole numbers.
- 1
Write hypotheses
Alternative: there is an association. Null: any pattern is due to chance
- 2
Draw the table
Observed frequencies in rows and columns, with totals
- 3
Work out each E
Row total x column total / grand total
- 4
Check E
Every expected frequency should be 5 or more
A row total is 40, a column total is 30 and the grand total is 120. What is E for that cell?
A worked example
Find each expected frequency, work out (O - E)² / E for every cell, then add the four values to get chi-squared.
Example data (invented for teaching). 80 people were observed: 40 men and 40 women. 40 held a door and 40 did not.
Every E = 40 x 40 / 80 = 20.
For each cell, (O - E)² / E:
- men held: (14 - 20)² / 20 = 36 / 20 = 1.8
- men did not: (26 - 20)² / 20 = 1.8
- women held: (26 - 20)² / 20 = 1.8
- women did not: (14 - 20)² / 20 = 1.8
χ² = 1.8 + 1.8 + 1.8 + 1.8 = 7.2
- Observed
- Expected
In the example, what is (14 - 20)² / 20?
Degrees of freedom and significance
Work out degrees of freedom, find the critical value at p ≤ 0.05, then compare: the result is significant if the calculated value is equal to or greater than the critical value.
Degrees of freedom = (rows - 1) x (columns - 1). A 2 x 2 table has df = 1.
For a non-directional (two-tailed) hypothesis at p ≤ 0.05, the critical values are 3.84 for df 1, 5.99 for df 2 and 7.81 for df 3. For a directional hypothesis with df 1, it is 2.71.
In the example, 7.2 is greater than 3.84, so the result is significant. Reject the null hypothesis and accept the alternative. The probability that the pattern is due to chance is 5% or less.
- 1
Work out df
(rows - 1) x (columns - 1)
- 2
Find the critical value
Use the table for your df, significance level and tail
- 3
Compare
Is the calculated value equal to or greater than the critical value?
- 4
Decide
If yes: significant, reject the null. If no: not significant, retain the null
A calculated chi-squared of 6.2 has df = 2 and a critical value of 5.99 at p ≤ 0.05. Is it significant?
Strengths, limits and writing it up
Chi-squared suits nominal data and is simple, but it shows association not cause, needs large enough expected frequencies, and loses detail about the data.
Strengths: it is designed for frequency data, so it fits tallies from observations. It is simple to calculate by hand. It does not need scores or a normal distribution.
Limitations: it shows an association, not cause. It needs expected frequencies of 5 or more. It does not show direction, so compare observed with expected frequencies. It loses detail, and very large samples can make tiny differences significant.
In a write-up, report the test, why it was chosen, the calculated value, df, critical value and p level, and what it means for your hypotheses.
- 1
Name the test and why
Nominal data, independent groups, test of association
- 2
Give the numbers
Calculated value, df, critical value and p level
- 3
State the decision
Significant or not; reject or retain the null hypothesis
- 4
Explain what it means
Say what the association is, using the observed data
- 5
Note limits
Cause, sample size and observer bias
Name one limitation of the chi-squared test.
Try an exam question
Explain two conditions that must be met before a chi-squared test can be used.
[4 marks]
- [1]States one condition, e.g. the data must be frequencies (counts) in categories.
- [1]Explains it, e.g. the test compares observed with expected counts, so it cannot use percentages or scores.
- [1]States a second condition, e.g. the groups must be independent or every expected frequency must be 5 or more.
- [1]Explains it, e.g. each person must appear in one cell only, or small expected frequencies make the result unreliable.
That's the notes covered.
Carry on to the next subtopic.
Try a question
Identify the level of data that the student's tallies produce.
1 mark, marked against the mark scheme
Identify the level of data that the student's tallies produce.
1 mark, marked against the mark scheme
