197. Chi-Square Independence
Compares two observed categorical distributions.
- : observed frequency in cell
- : expected frequency in category calculated as:
- : Row total for row
- : Column total for column
- : Total number of observations
Example
You own a café, and you think you can make more money by getting people to buy larger drinks in the morning. You want to see if the time of day and coffee size are related, so you collect a simple random sample of last month’s orders. The observed data is below. At test if they are related.
| Observed | Small | Medium | Large | Total |
| Morning | 7 | 14 | 29 | 50 |
| Afternoon | 7 | 7 | 15 | 29 |
| Evening | 10 | 7 | 4 | 21 |
| Total | 24 | 28 | 48 | 100 |
| Expected | Small | Medium | Large | Total |
| Morning | 50 | |||
| Afternoon | 29 | |||
| Evening | 21 | |||
| Total | 24 | 28 | 48 | 100 |
p-value < alpha
0.0164 < 0.05
Critical value < Chi^2 statistic
9.49 < 12.13
Example
Genre Preference by Age Group
| Action | Comedy | Drama | ||
| Under 30 | 60 | 50 | 30 | 140 |
| Above 30 | 20 | 40 | 60 | 120 |
| 80 | 90 | 90 | 260 |
| Action | Comedy | Drama | ||
| Under 30 | 140 | |||
| Above 30 | 120 | |||
| 80 | 90 | 90 | 260 |
| Action | Comedy | Drama | ||
| Under 30 | 140 | |||
| Above 30 | 120 | |||
| 80 | 90 | 90 | 260 |
| Action | Comedy | Drama | ||
| Under 30 | 140 | |||
| Above 30 | 120 | |||
| 80 | 90 | 90 | 260 |
| Action | Comedy | Drama | ||
| Under 30 | ||||
| Above 30 | ||||
Since , reject : genre preference depends on age group, driven almost entirely by action and drama ( and ) rather than comedy ().