SECTION 01 / 8

Two-variable questions and contingency tables

2 min read
On this page 5 headings

So far we have described one variable at a time. Now we ask whether two characteristics vary together. For example, does smartphone ownership differ across income groups? We need two values recorded for the same case.

A quick review before starting

Earlier ideaWhy it matters now
Case and variableKeep both values paired with the correct person.
Categorical or numericalThe variable types determine the table or graph.
Frequency and relative frequencyCounts summarize cases; shares allow fair group comparisons.
Mean, median, spread and percentilesUse these to compare numerical distributions within groups.

Choose the method from the variable types

Variable pairFirst toolExamples
Categorical + categoricalTwo-way contingency tableIncome group and phone ownership
Numerical + numericalScatterplotHouse size and price
Categorical + numericalSeparate group distributionsGroup label and exam marks

A contingency table counts combinations

Each interior cell counts cases with both its row category and its column category. Row and column totals are marginal totals; the bottom-right number is the grand total. Each case is counted once in the body of a complete two-way table.

Gender in lecture surveyNo phoneOwns phoneRow total
Female103444
Male144256
Column total2476100

Of the 100 surveyed students, 44 are female, 56 are male, and 76 own phones. The missing female/non-owner cell is 44−34 = 10. The male/non-owner cell is 56−42 = 14. Check 10+34+14+42 = 100.

The same count of 34 answers different questions depending on the comparison group.
The same count of 34 answers different questions depending on the comparison group.

A second example: income and ownership

Income groupNo phoneOwns phoneTotal
Low9514
Medium273966
High21820
Total3862100

Income group is ordinal, so retain Low, Medium, High (or the reverse order). Ownership is nominal. The largest owner count is Medium = 39, but that group also contains the most people. Counts alone do not tell us which income group has the highest ownership share.

Create a two-way summary in a spreadsheet

Begin with one row per participant and a column for each variable. In a pivot table, place one variable in Rows and the other in Columns. Set Values to count a complete ID or category field, using a count appropriate for text. Check blanks and totals. Do not add the Total row as if it were another observation when graphing.

Try it yourself

In the income table, how many participants are both low income and non-owners?

Show explained answer

9. This is the intersection of the Low row and No phone column.

Try it yourself

A row total is 30 and its Yes count is 18. Find No.

Show explained answer

30−18 = 12, assuming Yes and No cover every response exactly once.

Try it yourself

Can house size and house price be analyzed by a category contingency table without changing them?

Show explained answer

They are numerical variables, so a scatterplot is the natural starting point. Binning them into categories loses detail.

Source: Lectures 4.1 and 4.2. Extra examples and diagrams are teaching material prepared for these notes.

YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑