hanegreefs.com/Statistics I
Chapter 2 of 10

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".

Worked example

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.

1

Total

210 + 90 + 60 + 40 = 400 visits
2

Relative frequencies

210/400 = 0.525, 90/400 = 0.225, 60/400 = 0.15, 40/400 = 0.10
3

As percentages

52.5%, 22.5%, 15% and 10%; together 100%
Answer

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.

Common trapDo not use a histogram for a categorical variable. Histograms are for quantitative variables, and their bars touch.

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:

PercentageDivide the cell byRead it as
Total percentagethe grand total"of all cases, x% are in this row and this column"
Row percentageits row total"of the cases in this row, x% are in this column"
Column percentageits column total"of the cases in this column, x% are in this row"
Worked example

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.

1

Totals

rows 240 and 260; columns card 270, cash 110, app 120; grand total 500
2

Total percentage of "under 30 and app"

90/500 = 18%
3

Row percentage

90/240 = 37.5% of the young shoppers pay by app
4

Column percentage

90/120 = 75% of the app payers are young
5

Marginal distribution of payment

card 54%, cash 22%, app 24%
Answer

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.

Common trapAssociation in a table is not proof of causation. Another variable, such as income, may drive both.

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.

Loading cards
Question
Click, tap or press space to flip
Answer

Multiple choice (8)

Question 1 · Chapter 2

500 women name their preferred car type (sedan, SUV, hatchback, van). Best display?

Why: One categorical variable.
Question 2 · Chapter 2

In a table with brands as columns, 214 of the 330 people who prefer brand B are male. 214/330 is a...

Why: The base is the brand total.
Question 3 · Chapter 2

A table has 650 respondents; 156 prefer brand C. The share preferring C is about...

Why: 156/650 = 0.24.
Question 4 · Chapter 2

Which statement shows independence in a contingency table?

Why: Equal conditional distributions mean independence.
Question 5 · Chapter 2

A chart shows sales with 3D cylinders whose widths also grow with the value. It violates...

Why: Area grows faster than the value.
Question 6 · Chapter 2

The column totals of a contingency table form...

Why: Totals of one variable on its own.
Question 7 · Chapter 2

Which display compares the conditional distributions of smoking status in three age groups?

Why: One 100% bar per age group.
Question 8 · Chapter 2

In the payment example, 75% of the app payers are young. This is a...

Why: Base: the app column total.

Exam-style open questions (2)

Open question · Chapter 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.
Open question · Chapter 2

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.