Tests of Independence
To see whether two categorical variables are related, fill in the table you'd expect if they had nothing to do with each other, then compare it with the real one. It's the same chi-square idea as goodness of fit, and big gaps are evidence of a relationship.
What the symbols mean
- Expected count
The count in a cell if the variables were independent.
- Number of rows
Categories of one variable.
- Number of columns
Categories of the other variable.
Explanation
A test of independence is simply a check of whether two categorical traits (things you sort people into groups by) are connected: does knowing someone's age group tell you anything about whether they prefer cats or dogs? "Independent" here means exactly that knowing one tells you nothing about the other, the same meaning it had for events in probability. In goodness of fit, a claim handed us the expected counts; now we work out the counts "no connection" would predict. The formula is just that: the row total (how many people are in this group), times the column total (how many gave this answer), divided by (everyone). After that it's the same you already know, so there's really only one new piece here.
Why that expected count? Remember from probability that independent events multiply: . Estimate each probability from the table's totals and multiply by to turn it into a count: . Two of the 's cancel, and you're left with row total times column total over . In plain words: if 60% of everyone said yes, then under independence 60% of each group should say yes too.
Procedure: : the variables are independent. Compute every expected count, then over all cells, with degrees of freedom.
Why ? The row and column totals are fixed, so in each row the last cell is forced, and in each column the last cell is forced too. Only an block of cells is free to vary.
A test for homogeneity (do several populations share one distribution?) uses exactly the same arithmetic.
A common mistake. Rejecting independence says the variables are associated. It's tempting to read that as one causing the other, but the test can't tell you that. Older people might prefer dogs for reasons that have nothing to do with age itself.
See it
Worked examples
100 people: younger prefer cats 30, dogs 20; older prefer cats 20, dogs 30. Test independence at (critical value , ).
- 1
Every row and column total is 50, so each expected count is .
Practice
Type your answer and check it. Solve them all to complete the lesson.
In the pets table, what is the expected count for younger cat lovers?
Compute .
How many degrees of freedom does a 3 × 4 table have?
For the pets table, with critical value 3.841, what is the decision?
What does "independent" mean here?
In a survey of 200 people, 60 of the 100 younger ones and 40 of the 100 older ones prefer streaming to cable. Under independence, what is the expected count of younger people who prefer streaming?
Compute for that table.
The hardest one here. Get it, and you've got this lesson.
A table has row totals 60 and 40 and column totals 30, 50 and 20, with . Find the expected count in row 2, column 3, and the degrees of freedom. Enter both.
Where it's used
Is a side effect related to the dose group? Do voting preferences differ by region? Does a customer's segment relate to the product they buy? All independence tests.