Displaying and describing categorical data
Frequency tables, bar charts and pie charts with the area principle, contingency tables with total, row and column percentages, marginal and conditional distributions, independence in a table, and segmented bar charts.
Textbook: Ch. 2 · Sessions: Module 2, lecture 2, tutorial 2 · About 45 minutes
Frequency tablesImportant
To summarise one categorical variable, count how many cases fall in each category. A frequency table lists the categories with their counts (absolute frequencies), and usually also the relative frequencies: each count divided by the total, shown as a percentage. Rare categories can be pooled into "other".
Where do the visitors come from?
A web shop logs 400 visits: 210 via a search engine, 90 typed the address directly, 60 came from social media and 40 from an email campaign.
Total
Relative frequencies
As percentages
More than half of the visits come from search. Because of rounding, a column of percentages can add up to 99.9% or 100.1%; that is fine, but say so.
Bar charts, pie charts and the area principleImportant
A bar chart shows one bar per category, with a height equal to the count or the percentage. The bars stand apart with gaps, because the categories are separate. Order the bars from tall to short unless the variable is ordinal, label both axes and give the units.
A pie chart shows how one whole breaks into parts. It works when there are few categories and the shares are close to simple fractions (a half, a quarter), but comparing two pies is hard, so a bar chart is usually the better choice.
Every display must respect the area principle: the area taken by a part of the chart must be proportional to the value it represents. Three-dimensional effects, pictures of different sizes or axes that do not start at zero break this rule; decoration that adds nothing is called chart junk.
Contingency tables and the three percentagesImportant
To study two categorical variables together, build a contingency table: one variable in the rows, the other in the columns, and in every cell the number of cases with that combination. The row and column totals are the marginal distributions: each on its own is just the frequency table of one variable.
For every cell you can compute three different percentages. The skill the exam tests is choosing the right base:
| Percentage | Divide the cell by | Read it as |
|---|---|---|
| Total percentage | the grand total | "of all cases, x% are in this row and this column" |
| Row percentage | its row total | "of the cases in this row, x% are in this column" |
| Column percentage | its column total | "of the cases in this column, x% are in this row" |
Payment method by age group
500 shoppers: under 30 paid 120 times by card, 30 times in cash and 90 times by app; customers of 30 or older paid 150 times by card, 80 times in cash and 30 times by app.
Totals
Total percentage of "under 30 and app"
Row percentage
Column percentage
Marginal distribution of payment
The same cell gives 18%, 37.5% or 75% depending on the base. Write the sentence first, then divide.
Conditional distributions and independenceImportant
A conditional distribution shows the distribution of one variable only for the cases that meet a condition on the other: the row percentages of one row, or the column percentages of one column.
If the conditional distribution of one variable is the same in every category of the other variable, the two variables are independent in that table. If the distributions differ, the variables are associated. In the payment example, 37.5% of the young pay by app against 30/260 ≈ 11.5% of the older shoppers, so payment method and age are clearly associated.
A segmented (stacked) bar chart displays conditional distributions: every bar is one group scaled to 100% and split into segments. A mosaic plot also makes the bar widths proportional to the group sizes, so it respects the area principle even better.
Key takeaways
- Frequency table: counts and percentages per category.
- Bar chart for one categorical variable; pie only for parts of one whole.
- Area principle: area proportional to value, no 3D effects.
- Total, row and column percentages differ only in the base you divide by.
- Marginal distribution = totals; conditional distribution = percentages within one row or column.
- Same conditional distribution in every group means independence in the table.
Multiple choice (8)
500 women name their preferred car type (sedan, SUV, hatchback, van). Best display?
In a table with brands as columns, 214 of the 330 people who prefer brand B are male. 214/330 is a...
A table has 650 respondents; 156 prefer brand C. The share preferring C is about...
Which statement shows independence in a contingency table?
A chart shows sales with 3D cylinders whose widths also grow with the value. It violates...
The column totals of a contingency table form...
Which display compares the conditional distributions of smoking status in three age groups?
In the payment example, 75% of the app payers are young. This is a...
Exam-style open questions (2)
Percentages from a table
A survey of 800 employees: of the 300 who work remotely, 210 are satisfied; of the 500 who work at the office, 250 are satisfied. Build the table, give the total, row and column percentage for "remote and satisfied", and judge independence.
Show the worked outline
- Satisfied: 210 + 250 = 460; not satisfied: 90 + 250 = 340; total 800.
- Total %: 210/800 = 26.25%. Row % (remote row): 210/300 = 70%. Column % (satisfied column): 210/460 ≈ 45.7%.
- Satisfaction is 70% for remote and 50% for office workers: the conditional distributions differ, so work mode and satisfaction are associated.
Choose and criticise a display
A manager shows the market shares of six brands as a 3D pie with one slice pulled out. What would you change and why?
Show the worked outline
- Use a bar chart, ordered from the largest to the smallest share, with percentages on the axis.
- The 3D tilt and the pulled-out slice distort areas and break the area principle.
- Six slices of similar size are hard to compare in a pie.
LabContingency table lab
The default numbers are the payment example above.
LabDisplay and percentage sorter
Practise the choice the exam asks for most.