Chi-square test of independence
Test whether product preference depends on age group by finding expected counts, the chi-square statistic, degrees of freedom and the p-value from a contingency table, and say where the difference lies.
It opens on
Of 400 customers, 130 are under 30 and 130 prefer Outdoor. If preference ignored age, how many under-30s would prefer Outdoor: about 30, 42 or 60?
Why it matters
Marketing and merchandising decisions turn on whether groups of customers really prefer different things, or whether a pattern in a survey table is only chance.
Good to know first
- contingency table
Step by step
Expected counts under independence
Compute the expected count for every cell from the row and column totals.
For under 30 and Outdoor, E = 130 × 130 / 400 = 42.25, about 42, which answers the opening question, against the observed 60.
E = 130 × 130 / 400 = 42.25
A common mix-up
The expected counts must be whole numbers.
In fact: They are averages under independence, so they can have decimals.
The statistic and the decision
Compute the chi-square statistic and its degrees of freedom, compare with the critical value and decide.
For under 30 and Outdoor, (60 − 42.25)² / 42.25 = 315.06 / 42.25 = 7.457.
(60 − 42.25)² / 42.25 = 7.457
A common mix-up
A large chi-square shows that one variable causes the other.
In fact: It shows only that the two are associated, not why, and an observational survey cannot establish cause.
Where the difference lies, and the conditions
Use the contributions and row percentages to describe the association, and check the conditions for the test.
A common mix-up
A significant chi-square tells us which groups differ and how.
In fact: It only says the variables are associated; the contributions and row percentages show the pattern.
Try it
In a 2 by 2 table, a row total is 60, a column total is 50 and the grand total is 200. Find the expected count of that cell.Answer
60 × 50 / 200 = 15
Hint: Row total × column total / grand total
A cell has observed 30 and expected 24. Find its contribution to χ².Answer
(30 − 24)² / 24 = 1.5
Hint: (O − E)² / E
A test of a region by product table gives p = 0.30. Write the conclusion in context at α = 0.05.Answer
Fail to reject H₀; there is not enough evidence that product preference depends on region
Hint: Do not say accept
What is the expected count for 30 to 49 and Outdoor?Answer
140 × 130 / 400 = 45.5
How many degrees of freedom does a table with 4 rows and 3 columns have?Answer
(4 − 1)(3 − 1) = 6
