Joint and marginal frequencies
When every person answers two questions, how do you count them without losing which answers went together?
Where you are 3 in Two-way tables
Why this exists
A frequency table counts one variable. Ask the same people a second question and a second table counts that, but two separate tables lose which answers came from the same person.
At a made-up camp, 12 campers each chose the lake or the forest trail for an afternoon walk. 5 chose the lake, and 6 are under 12. How many campers under 12 chose the lake? Any number from 0 to 5 fits those two counts. To answer, you must count the campers by both answers at once, which is what a two-way table does. It is where every question about whether two variables are connected starts.
Definition
The data are two categorical variables recorded for each member of a group of individuals (people, orders, animals). Each individual has exactly one category of each variable.
A two-way table has one row for each category of one variable and one column for each category of the other. The cell where a row meets a column counts the individuals with both that row’s category and that column’s category. A column on the right holds the row totals, and a row along the bottom holds the column totals. For the 12 campers (made-up data):
| Lake | Forest trail | Total | |
|---|---|---|---|
| Under 12 | 4 | 2 | 6 |
| 12 and over | 1 | 5 | 6 |
| Total | 5 | 7 | 12 |
- A joint frequency is the number in one cell of the body: how many individuals have one category of the first variable and one of the second. The 4 counts campers under 12 who chose the lake.
- A marginal frequency is a row or column total: how many individuals have one category of one variable, whatever their other answer. The 5 counts all campers who chose the lake. These totals sit in the margins, hence the name.
- The grand total, in the bottom right corner, is the number of individuals.
A joint relative frequency is a joint frequency divided by the grand total, and a marginal relative frequency is a marginal frequency divided by the grand total. Here \tfrac{4}{12} = \tfrac{1}{3} of the campers are under 12 and chose the lake, and \tfrac{5}{12} chose the lake.
Which variable runs down the side is a free choice; swapping them changes none of the counts.
Intuition
Picture each camper as a dot, dropped into the one cell that matches both answers.
Counting across a row forgets the walk question and counts by age alone; counting down a column forgets age. So the right margin is the frequency table for age, the bottom margin the one for the walk, and the body the joint table. The margins can be found from the body by adding, but not the other way round, which is what the opening question ran into.
Results
Totals. Each row total is the sum of the joint frequencies across its row, each column total the sum down its column, and the row totals, the column totals and all the joint frequencies each add to the grand total. With cells a, b in the first row and c, d in the second:
Relative frequencies. Dividing every entry by the grand total n keeps these sums with n replaced by 1: the joint relative frequencies add to 1, the marginal relative frequencies of each variable add to 1, and each marginal relative frequency is the sum of the joint relative frequencies in its row or column.
Missing entries. A row or column with only one unknown entry, counting its total as an entry, gives that entry: subtract the known cells from the total, or add the cells when the total is the unknown.
Why it is true
Each individual has exactly one category of each variable, so each lands in exactly one cell: nobody is left out and nobody is counted twice. Everyone in a row’s category is in exactly one of that row’s cells, so the cells add to the row total; columns work the same way.
Adding the row totals adds every cell once, grouped by row; adding the column totals adds the same cells grouped by column. Reordering a sum does not change it, by the commutative property, and regrouping does not either, by the associative property, so both equal the grand total. Dividing by n turns it into \tfrac{n}{n} = 1.
The margins alone cannot fix the body. With two rows and two columns and all totals known, choosing a fixes b, c and then d, but nothing in the totals fixes a itself.
Worked examples
Reading joint and marginal frequencies
At a made-up summer camp, each of 80 campers chose the lake or the forest trail for one afternoon.
| Lake | Forest trail | Total | |
|---|---|---|---|
| Under 10 | 18 | 7 | 25 |
| 10 to 13 | 14 | 16 | 30 |
| 14 and over | 9 | 16 | 25 |
| Total | 41 | 39 | 80 |
(a) How many campers aged 10 to 13 chose the forest trail? (b) How many campers chose the lake? (c) How many campers under 14 chose the lake? (d) Say whether each of 14, 39 and 80 is a joint frequency, a marginal frequency or the grand total, and what it counts.
Solution(a) Two features at once, so one cell, where “10 to 13” meets “Forest trail”. It holds 16, a joint frequency.
(b) One feature, whatever the age, so the Lake column’s total: 41, a marginal frequency, which is 18 + 14 + 9.
(c) “Under 14” is two rows, under 10 and 10 to 13. No camper is in both, so add the two Lake cells: 18 + 14 = 32.
(d) 14 is in the body: a joint frequency, campers aged 10 to 13 who chose the lake. 39 is in the bottom margin: a marginal frequency, all who chose the forest trail. 80 is the grand total.
Check. 25 + 30 + 25 = 80 and 41 + 39 = 80.
Building a table from a list
A made-up café coded its first 20 orders one morning by drink (T tea, C coffee, H hot chocolate) and size (S small, L large):
CL, TS, CS, HL, CL, TS, TL, CL, HS, CS, HL, TS, CL, CL, TL, HL, CS, TS, HS, CL
Build a two-way table of drink against size.
SolutionEach order belongs in exactly one of 3 \times 2 = 6 cells. One pass through the list, tallying each order in the cell matching both letters, skips none and counts none twice. Then add across and down:
| Small | Large | Total | |
|---|---|---|---|
| Tea | 4 | 2 | 6 |
| Coffee | 3 | 6 | 9 |
| Hot chocolate | 2 | 3 | 5 |
| Total | 9 | 11 | 20 |
Check. Both margins reach 20, the number of orders. A tally in the wrong cell would not show here; only a recount catches that.
Filling in missing cells
A made-up survey asked students which after-school activity they do most. Find the lost entries.
| Sport | Club | None | Total | |
|---|---|---|---|---|
| Grade 7 | 34 | a | 15 | b |
| Grade 8 | c | 27 | d | e |
| Total | 62 | f | 40 | 150 |
Look for a line, row or column, with only one unknown; solving it may leave another such line.
- Sport column: c = 62 - 34 = 28.
- None column: d = 40 - 15 = 25.
- Grade 8 row, now all cells known: e = 28 + 27 + 25 = 80.
- Total column: b = 150 - 80 = 70.
- Grade 7 row: a = 70 - 49 = 21, taking away 34 + 15 = 49.
- Club column: f = 21 + 27 = 48.
Check. The bottom row was never used: 62 + 48 + 40 = 150. It agrees.
Finding a miscopied cell
On a Saturday the same café served 90 drinks. The totals came from the till and are right, but one joint frequency was copied wrongly. Find and correct it.
| Small | Large | Total | |
|---|---|---|---|
| Tea | 12 | 10 | 22 |
| Coffee | 15 | 13 | 46 |
| Hot chocolate | 8 | 14 | 22 |
| Total | 35 | 55 | 90 |
Rows: tea 12 + 10 = 22 agrees; coffee 15 + 13 = 28, not 46; hot chocolate 8 + 14 = 22 agrees. Columns: small 12 + 15 + 8 = 35 agrees; large 10 + 13 + 14 = 37, not 55.
A wrong cell spoils only its own row and its own column, so it is where the coffee row meets the large column. Both lines give the true value: 46 - 15 = 31 and 55 - 10 - 14 = 31. The large coffee count is 31, its digits swapped in the copy, so both lines fell short by the same 18.
Joint and marginal relative frequencies
Turn the table of Example 1 into joint and marginal relative frequencies. What share of all the campers were under 10 and chose the lake, and what share chose the lake?
SolutionEvery share here is of the same whole, so divide every entry, body and margins, by 80:
| Lake | Forest trail | Total | |
|---|---|---|---|
| Under 10 | 0.225 | 0.0875 | 0.3125 |
| 10 to 13 | 0.175 | 0.2 | 0.375 |
| 14 and over | 0.1125 | 0.2 | 0.3125 |
| Total | 0.5125 | 0.4875 | 1 |
So \tfrac{18}{80} = 0.225: 22.5\% of all campers were under 10 and chose the lake. And \tfrac{41}{80} = 0.5125: 51.25\% chose the lake.
Check. The six joint relative frequencies add to 1:
Dividing the 18 by its row total 25 instead would give the share of the under-10s who chose the lake, a conditional relative frequency.
From relative frequencies back to counts
Another made-up school asked 200 students the activity question. Its report gave only these relative frequencies: Grade 7, 0.45; sport, 0.40; club, 0.35; Grade 7 and sport, 0.15; Grade 7 and club, 0.18. Rebuild the table of counts.
SolutionEach count is its relative frequency times 200: Grade 7 90, sport 80, club 70 (marginal), Grade 7 and sport 30, Grade 7 and club 36 (joint). Then fill one line at a time:
- Grade 8: 200 - 90 = 110. None: 200 - 80 - 70 = 50.
- Grade 7 and none: 90 - 30 - 36 = 24.
- Grade 8 and sport: 80 - 30 = 50; and club: 70 - 36 = 34; and none: 50 - 24 = 26.
| Sport | Club | None | Total | |
|---|---|---|---|---|
| Grade 7 | 30 | 36 | 24 | 90 |
| Grade 8 | 50 | 34 | 26 | 110 |
| Total | 80 | 70 | 50 | 200 |
Check. The Grade 8 row was never added: 50 + 34 + 26 = 110. It agrees.
Boundaries
- Each individual is in exactly one category of each variable. Categories must not overlap and must cover everyone: age groups “10 to 13” and “13 to 16” both claim a 13-year-old.
- The table counts individuals, not answers. If one person may tick several boxes, the cells add to more than the number of people and the totals above fail.
- Relative frequencies here are over the grand total. Over a row or column total they are conditional relative frequencies, a different question.
- The margins do not determine the body. Filling in a table needs enough cells to start from.
- A table describes the group counted. Claims about a larger group need a well-chosen sample: populations and samples.
Where this goes next
Comparing conditional relative frequencies row by row decides whether two variables are connected, which is association in a two-way table. For one individual picked at random, a joint relative frequency is the probability of a compound event. The chi-square statistic compares each joint frequency with what the margins alone would lead you to expect.
Exercises
Reading a two-way table
Exercises 1 to 3 use this made-up survey of 120 students.
| Sport | Club | None | Total | |
|---|---|---|---|---|
| Grade 7 | 27 | 18 | 11 | 56 |
| Grade 8 | 33 | 14 | 17 | 64 |
| Total | 60 | 32 | 28 | 120 |
- How many students (a) are in Grade 8 and do a club, (b) do no activity, (c) are in Grade 7? Which answers are joint frequencies and which marginal?
- How many students are in Grade 8 or do a sport, or both?
- How many students (a) do a sport or a club, (b) are in Grade 7 and do a sport or a club?
Building a table from a list
- Fifteen made-up campers gave their age and their walk, L for lake and F for forest trail: 8 L, 13 F, 11 L, 15 F, 9 L, 10 F, 14 L, 12 F, 7 F, 16 F, 13 L, 9 L, 11 F, 15 L, 10 L. Build a two-way table with age groups under 10, 10 to 13, and 14 and over.
- A made-up café’s 12 orders, coded by drink (T tea, C coffee) and size (S small, M medium, L large), were: TS, CM, CL, TM, CM, CS, TL, CM, TS, CL, CM, TM. Build the two-way table.
Filling in and correcting
- At a made-up camp of 90 campers, 40 are under 12, 51 chose the lake, and 23 are under 12 and chose the lake. Complete the table of age (under 12, 12 and over) against walk.
- In a made-up survey of 110 students, 64 are in Grade 8, 45 do a sport and 25 do none. In Grade 7, 18 do a sport and 9 do none; in Grade 8, 21 do a club. Complete the table.
- A made-up café served 60 drinks: tea, coffee and hot chocolate, small or large. There were 16 teas, 7 of them small, and 5 small and 9 large hot chocolates. It sold four times as many large coffees as small ones. Complete the table.
- This made-up camp table has the right totals, but one joint frequency was copied wrongly. Find and correct it.
| Lake | Forest trail | Total | |
|---|---|---|---|
| Under 10 | 12 | 9 | 21 |
| 10 to 13 | 15 | 16 | 34 |
| 14 and over | 8 | 17 | 25 |
| Total | 35 | 45 | 80 |
Joint and marginal relative frequencies
- From the table for exercises 1 to 3, give to three places: (a) the joint relative frequency of Grade 8 and none, (b) the marginal relative frequency of sport, (c) that of Grade 7.
- Turn your table from exercise 5 into joint and marginal relative frequencies, as fractions in lowest terms.
- A made-up café sells only tea and coffee, small or large. Its joint relative frequencies are tea and small 0.18, tea and large 0.27, coffee and small 0.35. (a) Find coffee and large. (b) Find the marginal relative frequencies of small and of tea. (c) Of 400 drinks, how many were large coffees?
- A cell holds 27 students, and its joint relative frequency is 0.15. How many students are in the whole table?
Explaining and reasoning
- Answers from 30 people are tallied into a two-way table. The row totals add to 30 but the column totals add to 29. What is certain, and how can the faulty entry be found?
- A table with two rows and two columns has every row and column total equal to 10. Give two different such tables, and say what this shows about marginal frequencies.
- Which of these is true, and why? (a) The joint relative frequencies in a table add to 1. (b) All the marginal relative frequencies, right side and bottom together, add to 1.
- A survey asks 40 students “Tick all that apply: sport, club.” The answers are sorted into a table of grade against sport, club and none, and with every tick counted correctly the cells add to 47. How can that happen, and how should the table be set up?
- All the totals of a table with two rows and three columns are known. Explain why one joint frequency does not, in general, fix the table, and say which pairs of joint frequencies would.
Answers
- (a) 14 (b) 28 (c) 56. (a) is a cell, a joint frequency; (b) and (c) are a column total and a row total, marginal frequencies.
- 91. 64 + 60 = 124 counts the 33 Grade 8 sport students twice, so 124 - 33 = 91. Or add the cells: 27 + 33 + 14 + 17 = 91.
- (a) 92, from 60 + 32. (b) 45, from 27 + 18.
- Lake: 3 under 10, 3 aged 10 to 13, 2 aged 14 and over. Forest trail: 1, 4 and 2. Row totals 4, 7, 4; column totals 8 and 7; grand total 15.
- Tea: small 2, medium 2, large 1, total 5. Coffee: small 1, medium 4, large 2, total 7. Column totals 3, 6, 3; grand total 12.
- Under 12 and forest: 40 - 23 = 17. Aged 12 and over: 90 - 40 = 50. Forest total: 90 - 51 = 39. Aged 12 and over, lake: 51 - 23 = 28; forest: 50 - 28 = 22. Check: 17 + 22 = 39.
- Grade 8 sport 45 - 18 = 27; Grade 8 none 25 - 9 = 16; Grade 7 total 110 - 64 = 46; Grade 7 club 46 - 18 - 9 = 19; club total 19 + 21 = 40. Check: 27 + 21 + 16 = 64.
- Tea large 9; hot chocolate total 14; coffee total 60 - 16 - 14 = 30. With s small coffees, s + 4s = 30, so s = 6 and 24 large. Small total 7 + 6 + 5 = 18, large total 9 + 24 + 9 = 42, and 18 + 42 = 60.
- The 16 (aged 10 to 13, forest trail) should be 19. Only that row (31, not 34) and that column (42, not 45) fail, and 34 - 15 = 19 and 45 - 9 - 17 = 19 agree.
- (a) \tfrac{17}{120} \approx 0.142 (b) \tfrac{60}{120} = 0.500 (c) \tfrac{56}{120} \approx 0.467.
- Divide by 12. Tea: \tfrac{1}{6}, \tfrac{1}{6}, \tfrac{1}{12}, total \tfrac{5}{12}. Coffee: \tfrac{1}{12}, \tfrac{1}{3}, \tfrac{1}{6}, total \tfrac{7}{12}. Sizes: \tfrac{1}{4}, \tfrac{1}{2}, \tfrac{1}{4}; grand total 1.
- (a) 1 - 0.18 - 0.27 - 0.35 = 0.20, since the joint relative frequencies add to 1. (b) Small 0.18 + 0.35 = 0.53; tea 0.18 + 0.27 = 0.45. (c) 0.20 \times 400 = 80.
- 180, since 27 \div 0.15 = 180.
- Some total is not the sum of its own cells: if every total were, both margins would add to the sum of all the cells. Re-adding each row and column finds it. If the cells themselves do not add to 30, a tally was also missed or doubled and the answers must be recounted.
- Rows 5, 5 and 5, 5; or rows 2, 8 and 8, 2. Same margins, different bodies: marginal frequencies do not fix joint frequencies.
- Only (a). The body counts everyone once, so it adds to \tfrac{n}{n} = 1. Each margin also adds to 1, so both together add to 2.
- A student doing both ticks both boxes and lands in two cells, so 47 - 40 = 7 students do both. Use the categories sport only, club only, both and none, so each student is in one cell.
- One cell fixes the rest of its column, but in the other two columns, adding 1 to two diagonally opposite cells and taking 1 from the other two keeps every total. Two cells in different columns suffice: each fills its column, then each row has one unknown left. Two in the same column do not, since the second adds nothing the column total did not give.