Two Categorical Variables
| English | Chinese | Pinyin |
|---|---|---|
| categorical | 分类 | fēn lèi |
| two-way table | 双向表 | shuāng xiàng biǎo |
| contingency table | 列联表 | liè lián biǎo |
| conditional relative frequency | 条件相对频率 | tiáo jiàn xiāng duì pín lǜ |
| segmented bar chart | 分段条形图 | fēn duàn tiáo xíng tú |
Two categories at once
- Sometimes both variables are categorical 分类 — like gender and favorite subject.
- Organize them in a two-way table 双向表 (also called a contingency table 列联表).
- Rows are the categories of one variable; columns are the categories of the other.
- Each cell holds the count of individuals in that row-and-column combination.
Marginal and joint
- The margins (row and column totals) give marginal frequencies — one variable, ignoring the other.
- A single inner cell gives a joint frequency — both categories at once.
- Divide by the grand total to get relative frequencies (proportions).
- Marginal relative frequency = a total ÷ grand total; joint = a cell ÷ grand total.
Conditional relative frequency
- A conditional relative frequency 条件相对频率 restricts attention to one group, then finds a proportion inside it.
- "Of the girls, what fraction chose science?" — divide that cell by the girls' row total.
- The key is the denominator: a row total (or a column total), not the grand total.
- Conditionals are how we compare groups fairly, even when the groups differ in size.
Showing it as bars
- A side-by-side bar chart puts each group's bars next to each other for comparison.
- A segmented bar chart 分段条形图 stacks the proportions within each group into one full bar.
- Segmented bars are ideal for comparing conditional distributions — each bar sums to $100\%$.
- If the segments line up the same in every bar, the variables look unrelated.
The three "frequencies" differ only in their denominator. Joint = cell ÷ grand total. Marginal = a row/column total ÷ grand total. Conditional = cell ÷ that row (or column) total. Mixing them up is the classic two-way-table mistake — always ask "a fraction of what group?" before you divide.
$100$ students: of $60$ girls, $36$ chose science; of $40$ boys, $16$ chose science.
- Joint (girl and science): $36/100 = 36\%$.
- Marginal (science overall): $(36+16)/100 = 52\%$.
- Conditional (science given girl): $36/60 = 60\%$ — note the denominator is the girls' total.
A two-way (contingency) table cross-classifies two categorical variables. Joint and marginal relative frequencies divide by the grand total; a conditional relative frequency divides a cell by its row or column total. Display the relationship with a side-by-side or segmented bar chart.
A categorical breakdown
Each slice is one category's share of the whole.
A table that cross-classifies two categorical variables is a ___ table (two words, first word).
A two-way (contingency) table.
Of 60 girls, 36 chose science. What is the conditional relative frequency of science given girl (as a decimal)?
36 ÷ 60 = 0.60 — divide by the girls' row total.
A joint relative frequency divides a single cell by the ___.
Joint = cell ÷ grand total; conditional uses a row/column total.
In a segmented bar chart comparing groups, each bar sums to 100%.
Segmented bars show conditional distributions, each totaling 100%.
Match each frequency to its denominator.
Only conditional uses a group (row/column) total as the denominator.