A two-way table counts individuals by two categorical variables at once. To see whether the variables are associated, compare the distribution of one variable across the groups of the other. Edit the counts, switch which variable you condition on, and watch the graphs and the explanation update.
Type any counts. The totals, graphs, and conditional distributions update as you type.
Each individual lands in exactly one cell: one category of the row variable and one category of the column variable. The row and column totals are in the margins, and the grand total is in the corner.
The marginal distribution of a variable uses only the totals in the margin. It ignores the other variable completely, so it cannot show association.
A conditional distribution looks at only the individuals in one group and gives the proportion in each category of the other variable. Each conditional distribution adds up to 1 (or 100%).
Two categorical variables are associated if the conditional distributions differ across groups. If every group has the same conditional distribution, there is no association.
Side-by-side bars show counts, which can mislead when groups are different sizes. Segmented bars show proportions, so each bar is 100% tall. A mosaic plot is a segmented bar chart whose bar widths show the group sizes.
Finding an association in observational data does not show that one variable causes the other. A lurking variable might explain both.
The table: 200 students by grade (9th, 12th) and whether they drive to school. 9th: 6 drive, 94 do not. 12th: 58 drive, 42 do not.
| Question | What to use | Work | Answer |
|---|---|---|---|
| What is the marginal distribution of driving? | Column totals ÷ grand total | 64 ÷ 200, 136 ÷ 200 | 32% drive, 68% do not |
| What proportion of 12th graders drive? | Cell ÷ 12th-grade total | 58 ÷ 100 | 0.58 |
| What proportion of drivers are 12th graders? | Cell ÷ drivers total | 58 ÷ 64 | about 0.906 |
| Is grade associated with driving? | Compare conditional distributions | 0.06 for 9th vs. 0.58 for 12th | Yes. The proportions differ a lot. |
| Which graph should you use to compare grades? | Groups = the explanatory variable | One bar per grade, segmented by driving | Segmented bar chart (or mosaic) |
AP-style multiple choice. Pick an answer to see the explanation.
The vocabulary for topic 2.1. Read the list, flip through flashcards, or quiz yourself. For every term in the unit, see the Unit 2 terminology guide.