Unit 2 · Topic 2.1 · about 20 minutes

Tabular and Graphical Representations for the Distributions of Two Categorical Variables

Read a two-way table or a bar chart of two categorical variables, compare the groups fairly, and use it to support or reject a claim in context.

Predict first

A survey of 500 teens asked two questions: do you keep your phone in your bedroom overnight, and do you usually feel rested in the morning? Of the teens who keep the phone in the bedroom, 128 feel rested. Of the teens who keep it somewhere else, 117 feel rested. Which group does better at feeling rested?

Two variables, one table

Each teen in that survey gave two answers, and both are categorical: where the phone spends the night, and whether the teen usually feels rested. When every individual has a value for two categorical variables, a two-way table organizes the data. It is also called a contingency table. One variable labels the rows, the other labels the columns, and each cell counts the individuals who belong to that row and that column at the same time.

The totals sit in the margins. The last column holds the row totals, the bottom row holds the column totals, and the corner holds the grand total, here all 500 teens.

Phone location and feeling rested for 500 teens (counts)
RestedNot restedTotal
Phone in bedroom128192320
Phone elsewhere11763180
Total245255500

Counts or proportions

The cells of a two-way table can hold counts, which statisticians call frequencies, or proportions, called relative frequencies. Counts answer "how many?" They are bad at answering "which group is more likely?" because a bigger group piles up bigger counts in almost every cell.

To compare the groups fairly, divide each cell by the total for its own group. Then every row adds to 100%, and the rows can be laid side by side.

The same survey as a percent of each group (each row adds to 100%)
RestedNot restedTotal
Phone in bedroom40%60%100%
Phone elsewhere65%35%100%

Three graphs for two categorical variables

Each of these graphs shows the counts or percentages for the categories (also called levels) of one variable, drawn separately for each category of the other variable.

  • A side-by-side bar chart puts a cluster of bars for each group next to the clusters for the other groups. The bars can show counts or percentages.
  • A segmented bar chart gives each group a single bar that reaches 100%, divided into segments for the categories of the other variable. You compare matching segments from one bar to the next.
  • A mosaic plot is a segmented bar chart with bars of different widths. Each bar's width is proportional to the size of its group, so the area of every rectangle is proportional to the count in that cell.

Here is the sleep survey drawn twice as a side-by-side bar chart, first with counts and then with percentages of each group. Look at the two "rested" bars in each chart.

Bar chart of the four cells, as counts

050100150200Number of teensBedroom, rested: 128Bedroom, restedBedroom, not rested: 192Bedroom, not restedElsewhere, rested: 117Elsewhere, restedElsewhere, not rested: 63Elsewhere, not rested

In counts, the bedroom group has more rested teens (128) than the elsewhere group (117). That comparison is misleading, because the bedroom group is almost twice as large.

Bar chart of the four cells, as percentages within each group

0204060Percent of groupBedroom, rested: 40Bedroom, restedBedroom, not rested: 60Bedroom, not restedElsewhere, rested: 65Elsewhere, restedElsewhere, not rested: 35Elsewhere, not rested

In percentages the picture flips: 65% of the elsewhere group feel rested, compared with 40% of the bedroom group.

When are two variables associated?

Two categorical variables are associated when knowing one of them changes what you expect for the other. To check, compare the distribution of one variable across the categories of the other.

Overall, 245 of the 500 teens feel rested, which is 49%. If phone location and feeling rested were not associated, each group would show about 49% rested, and the two bars in a segmented bar chart would be split at the same height. Instead the split is 40% for one group and 65% for the other. For these 500 teens, phone location and feeling rested are associated.

Associated does not mean one causes the other. This was a survey, not an experiment, so it cannot show that the phone causes poor sleep. Teens who already sleep badly might be the ones who keep a phone within reach. 1.13 Experimental Design covers what it takes to show cause and effect.

Athletes at one high school by season and injury (counts)
SeasonMissed practice with an injuryDid notTotal
Fall54126180
Winter18102120
Spring27123150
Total99351450

Worked exampleTesting a trainer's claim

An athletic trainer recorded, for each of the 450 athletes in the table above, the season of their sport and whether they missed at least one practice because of an injury. The trainer claims that fall athletes are more likely to miss practice with an injury than athletes in the other two seasons. Do the data support the claim?

  1. Choose the comparison. The claim compares seasons, so compare the share injured within each season. Fall has the most injuries (54), but it also has the most athletes, so the count alone settles nothing.

  2. Find each season's percentage. Fall: 54180=0.30. Winter: 18120=0.15. Spring: 27150=0.18.

  3. Picture it. In a segmented bar chart the injured segment would fill 30% of the fall bar, 15% of the winter bar and 18% of the spring bar. The segments do not line up, so season and injury are associated for these athletes.

  4. Answer the claim in context. 30% of fall athletes missed practice with an injury, twice the rate for winter athletes (15%) and well above the rate for spring athletes (18%).

Answer.

Yes. The data support the claim: 30% of fall athletes missed practice with an injury, compared with 15% in winter and 18% in spring.

Check your understanding

1

A segmented bar chart shows how the students in each grade at a high school get to school: walking, bus or car. Which feature of the chart would show that grade and travel method are not associated?

2

A store asked 200 customers who paid with cash and 600 customers who paid by card whether checkout was quick enough. 150 of the cash customers and 420 of the card customers said yes. The manager says card customers are happier with checkout, since 420 is much more than 150. Which response is correct and gives a valid reason?

3

A mosaic plot compares ticket type (child, adult or senior) with whether a moviegoer bought popcorn. The bar for adult tickets is much wider than the other two bars. What does its width tell you?

4

A random sample of adults in a city were asked whether they own a pet and whether they live in an apartment or a house. Of the apartment dwellers, 38% own a pet. Of the house dwellers, 61% own a pet. Which claim do these results support?

5

A side-by-side bar chart shows the number of students who do and do not play a musical instrument, for 300 middle school students and 900 high school students in one district. The "plays an instrument" bar is taller for the high school students. What can you conclude from that?

Course alignment, for teachers

AP Statistics topic 2.1, Unit 2: Probability, Random Variables, and Probability Distributions.

  • Skill 4.A: Describe and compare tabular and graphical representations of data, as well as summary statistics.
  • Skill 4.B: Justify a claim based on statistical calculations and results.