Two-Way Tables
& Frequencies
Learn to organize categorical data and compute joint, marginal, and conditional relative frequencies from two-way tables.
What Is a Two-Way Table?
A two-way table (also called a contingency table) displays data for two categorical variables simultaneously. Rows represent one variable, columns represent the other, and each cell shows the count (frequency) of observations that fall into both categories.
Three Types of Frequency
Why Two-Way Tables Matter
Two-way tables let us detect relationships between categorical variables. For example: Is there an association between a student's grade level and their preferred lunch option? Frequencies alone can mislead when group sizes differ: relative frequencies level the playing field.
Formal Definitions
Anatomy of the Table
Joint vs. Marginal vs. Conditional
| Feature | Joint | Marginal | Conditional |
|---|---|---|---|
| Numerator | Cell count | Row or col total | Cell count |
| Denominator | Grand total | Grand total | Row or col total |
| Question answered | "What \(\%\) of all?" | "What \(\%\) of the total are in this category?" | "What \(\%\) given this group?" |
| Sum of all values | \(1\) | \(1\) (per variable) | \(1\) (per row/col) |
Step-by-Step Method
Example: Student Activities
A school surveyed 200 students about their grade level (Junior or Senior) and whether they participate in a sport. Build the two-way table:
| Plays Sport | No Sport | Total | |
|---|---|---|---|
| Junior | 45 | 35 | 80 |
| Senior | 70 | 50 | 120 |
| Total | 115 | 85 | 200 |
Joint Relative Frequencies
Divide each cell by the grand total (\(200\)) to get the joint relative frequency table:
| Plays Sport | No Sport | Total | |
|---|---|---|---|
| Junior | \(\frac{45}{200} = 0.225\) | \(\frac{35}{200} = 0.175\) | 0.400 |
| Senior | \(\frac{70}{200} = 0.350\) | \(\frac{50}{200} = 0.250\) | 0.600 |
| Total | 0.575 | 0.425 | 1.000 |
Conditional Relative Frequencies
Now divide each cell by its row total to find the conditional relative frequency given grade level:
| Plays Sport | No Sport | Total | |
|---|---|---|---|
| Junior | \(\frac{45}{80} = 0.5625\) | \(\frac{35}{80} = 0.4375\) | 1.000 |
| Senior | \(\frac{70}{120} = 0.58\overline{3}\) | \(\frac{50}{120} = 0.41\overline{6}\) | 1.000 |
From Raw Data to Table
A teacher records whether 150 students prefer online or in-person classes, sorted by whether they have a part-time job:
| Online | In-Person | Total | |
|---|---|---|---|
| Has Job | 54 | 36 | 90 |
| No Job | 18 | 42 | 60 |
| Total | 72 | 78 | 150 |
Conditioning on Columns
We can also divide by column totals instead of row totals. Using the same data: "Of all students who prefer online classes, what fraction has a job?"
| Online | In-Person | |
|---|---|---|
| Has Job | \(\frac{54}{72} = 0.750\) | \(\frac{36}{78} \approx 0.462\) |
| No Job | \(\frac{18}{72} = 0.250\) | \(\frac{42}{78} \approx 0.538\) |
| Total | 1.000 | 1.000 |
Common Mistakes
Summary at a Glance
| Frequency Type | Formula | Sums To |
|---|---|---|
| Joint (raw) | Cell value | Grand total |
| Joint relative | \(\frac{\text{cell}}{\text{grand total}}\) | 1 |
| Marginal relative | \(\frac{\text{row/col total}}{\text{grand total}}\) | 1 (per variable) |
| Conditional relative | \(\frac{\text{cell}}{\text{row or col total}}\) | 1 (per row/col) |
Question 1 of 5
A two-way table has a grand total of 300. One cell contains 60. What is the joint relative frequency for that cell?
Question 2 of 5
In a survey of 200 people, 80 are female. The marginal relative frequency for female is:
Question 3 of 5
In a row with a total of 90, one cell has a count of 27. The conditional relative frequency for that cell given its row is:
Question 4 of 5
Use this table. What is the conditional relative frequency of "Cats" given "Adults"?
| Dogs | Cats | Total | |
|---|---|---|---|
| Teens | 30 | 20 | 50 |
| Adults | 45 | 55 | 100 |
| Total | 75 | 75 | 150 |
Question 5 of 5
If the conditional relative frequencies for "Plays Sport" are \(56\%\) for juniors and \(58\%\) for seniors, what can you conclude?