STAT6135 Chap.5 Contingency Tables and Odds Ratios
Contingency Tables and Odds Ratios
Contingency Tables and Odds Ratios opens Part 3 with counts classified by one or two categorical variables. For a one-way table the simplest model makes every category equally likely, the expected count in each cell is the total divided by the number of categories, and Pearson's chi-squared statistic compares observed with expected counts on k minus 1 degrees of freedom.
The lecture solutions apply it to births by day of the week and find a very large statistic driven by the weekend deficit, and the worksheet repeats it with Premier League goals per season. Residuals show which cells cause the misfit.
For a two-way table the null hypothesis is independence: the expected count in a cell is its row total times its column total divided by the grand total, and the test has r minus 1 times c minus 1 degrees of freedom. The eye and hair colour data for 592 students reject independence decisively.
A chi-squared test says only whether there is association, so the chapter ends with the odds ratio, which measures its strength and direction in a 2 by 2 table, and with its confidence interval built on the log scale and exponentiated. Reversing the rows gives the reciprocal, and the same quantity reappears as the exponentiated coefficient in logistic regression.
What this chapter covers
- 01
One-way tables and the equiprobability model
- 02
Pearson's chi-squared statistic and degrees of freedom
- 03
Raw, standardised and adjusted residuals
- 04
Two-way tables and independence
- 05
Expected counts from row and column totals
- 06
Odds and the odds ratio
- 07
Log odds ratio confidence intervals
Worked example · free
Test a one-way table for equal shares
- 1There are 120 responses, so each expected count is 120 / 4 = 30.
- 2Contributions are 0, 64/30 = 2.13, 4/30 = 0.13 and 100/30 = 3.33, giving X² = 5.6.
- 1The degrees of freedom are 4 − 1 = 3 and the 5% critical value is 7.81.
- 1Since 5.6 is below 7.81, equal shares are not rejected; the fourth category contributes most.
Key terms
- Contingency table
- A table of counts cross-classified by the levels of two or more categorical variables.
- Pearson chi-squared statistic
- The sum over cells of squared differences between observed and expected counts divided by the expected counts.
- Independence model
- The model for a two-way table in which cell probabilities are the product of their row and column probabilities.
Contingency Tables and Odds Ratios FAQ
How are degrees of freedom found for a two-way table?
Multiply the number of rows minus one by the number of columns minus one. Under independence the row and column totals are fixed by the data, so only that many cells are free to vary. A four by four table therefore has nine degrees of freedom.
Why build the odds ratio interval on the log scale?
The sampling distribution of the log odds ratio is close to normal with a simple variance, the sum of the reciprocals of the four cell counts. The odds ratio itself is skewed, so the interval is formed for the log and both limits are exponentiated.
Does a significant chi-squared test show a strong association?
No. It shows that the data are unlikely under independence, but with a large sample even a weak association becomes significant. Measure strength and direction separately, for example with an odds ratio in a 2 by 2 table.
What does a large standardised residual in one cell tell me?
It marks a cell whose observed count is far from what the null model predicts, in units of the square root of the expected count. Values beyond about plus or minus 2 deserve comment, and they explain which categories drive a significant overall statistic.
Exam move
Compute expected counts, contributions and degrees of freedom by hand for one table of each type before using chisq.test, because the exam can ask for a single expected cell without output. Practise the odds ratio and its log-scale interval on a few invented 2 by 2 tables, including one where a cell count is small, and swap the rows to see the reciprocal appear.
Keep these tables: the same counts return as Poisson log-linear models in Part 4. When you report a test, give the statistic, its degrees of freedom, the critical value or p-value and one sentence on what the rejection or non-rejection means for the categories involved.
Working through Contingency Tables and Odds Ratios in STAT6135? Sia is AskSia’s AI Statistics tutor — ask any STAT6135 Contingency Tables and Odds Ratios question and get a clear, step-by-step explanation grounded in how STAT6135 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.