Chapter 14 · Statistics and data analysis
Reading and Building Two-Way Frequency Tables
Sort one group by two questions at once. Learn to read joint cells and totals in a two-way table, then build a table from a list or from stated facts.
You already know how to summarize one set of data, such as how many students walk to school. Now suppose you ask each student two questions: What grade are you in? and How do you usually get to school?
Each answer is a category: a group name, not a measurement. What a question records, such as grade, is a categorical variable: its values are categories. The people or things you collect data from are the subjects.
A two-way frequency table sorts the same subjects by two categorical variables at once. One variable labels the rows and the other labels the columns. Every number in the table is a frequency: an exact count of subjects, so it is a whole number that is or greater.
The table below shows the answers of students. Each student is in exactly one grade and gave exactly one of the three ways of getting to school.
| Grade | Walk | Bus | Car | Total |
|---|---|---|---|---|
Grade 7 | ||||
Grade 8 | ||||
Total |
The table holds three kinds of numbers.
- A joint cell sits where a row meets a column. It counts the subjects in two categories at once, one from each variable. The means that students are in Grade 7 and take the bus.
- A marginal total, or margin, sits at the edge of the table, in the Total row or the Total column. It counts the subjects in one category. The means that students are in Grade 8, however they travel. The means that students walk, whatever their grade.
- The grand total, , sits in the corner. It counts every subject once.
These numbers fit together. Add across the Grade 7 row: . Add down the Walk column: . The sums match the margins because each student is counted in exactly one joint cell.
Key concept
One subject, one joint cell
A joint cell counts the subjects that belong to two categories at once, one from each variable. A margin counts the subjects in one category. The grand total counts all the subjects.
Suppose every subject belongs to exactly one category of each variable. Then every subject is counted in exactly one joint cell. So the joint cells in a row add to that row's total, the joint cells in a column add to that column's total, and the row totals and the column totals each add to the grand total.
Worked example
Read and interpret the travel table
Use the table of students to answer four questions. (a) How many Grade 8 students take the bus? (b) How many students come by car? (c) How many Grade 7 students do not walk? (d) Of the students who walk, how many are in Grade 7?
(a) The question names one category from each variable: Grade 8 and Bus. That points to a joint cell. Go along the Grade 8 row until you reach the Bus column.
(b) The question names one category, Car, and says nothing about grade. That points to a margin: the Car column total, 18. You can confirm it by adding the Car column, because each student who comes by car is in exactly one of the two grades.
(c) The group that does not walk covers two categories in this table: Bus and Car. Each Grade 7 student is counted in exactly one of the three joint cells in the Grade 7 row, so add the Bus and Car cells. Subtracting the Walk cell from the row total gives the same count.
(d) The words 'of the students who walk' set the reference group: the Walk column. Its total is 24, which is not zero, so there is a group to compare with. Inside that column, read the Grade 7 cell. It is a joint cell, and now you also say which total it is part of.
Answer
(a) Grade 8 students take the bus. (b) students come by car. (c) Grade 7 students do not walk. (d) of the students who walk are in Grade 7.
Now build a table yourself. You start with raw data: a list that gives two answers for each subject. To turn the list into a two-way frequency table:
- Name the two variables and list the categories of each. Choose categories so that every subject fits exactly one category of each variable.
- Put one variable in the rows and the other in the columns. Swapping them changes the layout, not the counts. Add a Total row and a Total column.
- Tally each subject once: add one to the joint cell that matches both of its answers.
- Add across each row and down each column to fill in the margins. Then add the row totals, and separately the column totals. Both sums give the grand total.
- Check that the grand total equals the number of subjects in the list. It must, because each subject is tallied in exactly one joint cell.
The list below has the answers of club members.
| Member | Grade | Preferred meeting day |
|---|---|---|
1 | Grade 8 | Monday |
2 | Grade 7 | Friday |
3 | Grade 8 | Monday |
4 | Grade 8 | Friday |
5 | Grade 7 | Friday |
6 | Grade 8 | Monday |
7 | Grade 7 | Monday |
8 | Grade 8 | Monday |
9 | Grade 8 | Friday |
10 | Grade 7 | Friday |
11 | Grade 8 | Monday |
12 | Grade 8 | Monday |
Worked example
Build a table from a list
Twelve club members each gave their grade (Grade 7 or Grade 8) and the meeting day they prefer (Monday or Friday). Their answers are in the list above. Construct the two-way frequency table.
Name the variables and categories: grade (Grade 7, Grade 8) and preferred day (Monday, Friday). Each member is in exactly one grade and chose exactly one day, so each member belongs in exactly one joint cell. Put grade in the rows and day in the columns.
Tally the Grade 7 row. Count each Grade 7 member once, in the cell that matches both answers. Member 7 is Grade 7 and Monday. Members 2, 5 and 10 are Grade 7 and Friday.
Tally the Grade 8 row the same way. Members 1, 3, 6, 8, 11 and 12 are Grade 8 and Monday. Members 4 and 9 are Grade 8 and Friday.
Add across each row to get the row totals. Each sum counts every member of that grade, because each one sits in exactly one of the two day cells.
Add down each column to get the column totals. Each sum counts every member who chose that day, because each one sits in exactly one of the two grade cells.
Find the grand total from the row totals and again from the column totals. Both give 12, which matches the 12 members in the list. A different total would show a slip: a member missed, a member tallied twice, or an adding error.
Answer
The finished table has joint cells and in the Grade 7 row and and in the Grade 8 row, row totals and , column totals and , and grand total . It is shown below.
| Grade | Monday | Friday | Total |
|---|---|---|---|
Grade 7 | |||
Grade 8 | |||
Total |
Worked example
Build a table from stated facts
Sometimes you are given facts instead of a list. A survey asked students two yes-or-no questions: whether they play an instrument and whether they play a sport. Every student answered both questions. You are told that students play an instrument, play a sport, and play both. Construct the complete two-way frequency table.
Sort the facts by what each one describes. 50 counts all the students, so it is the grand total. 20 (instrument) and 31 (sport) each describe one category, so they are margins. 14 (both) describes a category from each variable, so it is a joint cell. Put instrument (Yes, No) in the rows and sport (Yes, No) in the columns, and write these four numbers in place.
Complete the Instrument Yes row. Each of the 20 instrument players answered exactly one of Yes or No about sport, so the two joint cells in this row add to 20. One of them is 14, so the other is 20 minus 14. It counts the players with no sport.
Complete the Sport Yes column for the same reason: its two joint cells add to 31. One of them is 14, so the other is 31 minus 14. It counts the sport players with no instrument.
Find the Instrument No row. The two row totals add to the grand total, because each student answered exactly one of Yes or No about an instrument. So this row total is 50 minus 20. Then subtract the 17 already in the row to get the last joint cell.
The two column totals add to the grand total, so the Sport No total is 50 minus 31. Then check it against the two joint cells in that column.
Check the whole table. The four joint cells must add to the grand total, because each student is counted in exactly one of them. Every number in the table is also a whole number that is 0 or greater, as a count must be.
Answer
Of the students, play both, play an instrument only, play a sport only, and play neither. The row totals are and , and the column totals are and . The finished table is shown below.
| Plays an instrument | Plays a sport: Yes | Plays a sport: No | Total |
|---|---|---|---|
Yes | |||
No | |||
Total |
Keep this idea: a two-way frequency table sorts one group of subjects by two categorical variables at once. A joint cell counts the subjects in two categories, one from each variable. A margin counts the subjects in one category.
When every subject fits exactly one category of each variable, each subject is counted in exactly one joint cell. So rows and columns add to their margins, and the row totals and the column totals each add to the grand total. Use these sums to check a table you read and to finish one you build, provided the stated facts give enough independent information to fix every cell.
Next, you will compare a count with a total to get a relative frequency. Each one must name its reference total (a row total, a column total, or the grand total), and that total must not be zero, because you divide by it.