Lesson 1.3 · Unit 1 · CED topics 1.3 and 1.4
One categorical variable: tables and graphs
When the variable is categorical, there are no averages to find. The question is how many observations fall in each category, and what share of the whole that is. This lesson shows how to organize one categorical variable in a table, draw it as a bar chart or a pie chart, and use the table or graph to support claims in context. It ends with the case the exam likes best: comparing two groups that have different sizes.
Learning objectives.
- 1.3.A. Construct categorical one-variable tabular representations.
- 1.3.B. Describe categorical one-variable tabular representations with summary statistics.
- 1.4.A. Construct categorical one-variable graphical representations.
- 1.4.B. Justify a claim using categorical one-variable graphical representations.
- 1.4.C. Compare multiple categorical one-variable tabular and graphical representations.
Essential knowledge.
- 1.3.A.1. A frequency table shows the number of observational units in each category of a categorical variable.
- 1.3.A.2. A relative frequency table shows the proportion of observational units in each category of a categorical variable.
- 1.3.B.1. Percentages, relative frequencies, and ratios all provide the same information as proportions.
- 1.3.B.2. Counts and relative frequencies of categorical variables reveal information that can be used to justify claims about the variables in context.
- 1.4.A.1. Bar charts, also called bar graphs, display frequencies (counts) or relative frequencies (proportions) for the categories of a single categorical variable. Each bar on a bar chart represents a category of the categorical variable of interest. The height or length of each bar corresponds to the frequency or relative frequency of the observational units in each category.
- 1.4.A.2. Pie charts are used to display frequencies (counts) or relative frequencies (proportions) for categorical data. Each slice on a pie chart represents a category of the categorical variable of interest. The area of each slice, as a fraction of the total area, corresponds to the relative frequency of observational units falling within each category. The sum of the slices’ areas together will equal 1, or 100% of the total area.
- 1.4.B.1. Graphical representations of a categorical variable reveal information that can be used to justify claims about the variable in context.
- 1.4.C.1. Frequency and relative frequency tables, bar charts, and pie charts can be used to compare two or more data sets in terms of the same categorical variable.
Frequency tables and relative frequency tables
A frequency table shows the number of observational units in each category of a categorical variable. A relative frequency table shows the proportion of observational units in each category: the count divided by the total number of observational units. The relative frequencies of all categories add up to 1 (or 100%, or very close to it if you round).
\[\text{relative frequency of a category}=\frac{\text{count in that category}}{\text{total count}}\]
Percentages, relative frequencies, and ratios all provide the same information as proportions. A proportion of 0.35, a percentage of 35%, and a ratio of 7 to 20 (35 out of every 100 is 7 out of every 20) say the same thing, and so does a statement comparing categories, such as "pizza was chosen \(28/20=1.4\) times as often as burritos."
Tables and graphs are used to justify claims about the variable in context. A claim such as "pizza is the favorite lunch of juniors" must be supported by the numbers that show it ("28 of the 80 juniors, or 35%, chose pizza, more than any other lunch"), and the claim should name the group and the variable.
Bar charts
A bar chart (or bar graph) displays the frequency (counts) or the relative frequency (proportions) for each category of a single categorical variable. Each bar stands for one category, and the height (or length) of the bar corresponds to the frequency or relative frequency of the observational units in that category. Some guidelines that make bar charts honest:
- Label both axes and give the chart a title that names the variable and the group.
- Start the frequency axis at 0. A bar's height is the data, so cutting off the bottom of the axis makes small differences look large.
- Leave gaps between the bars, since the categories are not points on a number line. Putting the categories in order of height, when they have no natural order, makes the chart easier to read.
Pie charts
A pie chart also displays frequencies or relative frequencies for one categorical variable. Each slice stands for a category, and the area of each slice, as a fraction of the total area, corresponds to the relative frequency of observational units in that category. The slices together make up the whole circle, which is 1, or 100%. A slice with relative frequency \(0.35\) takes up \(0.35\times360^\circ=126^\circ\) of the circle.
A pie chart is only appropriate when the categories together make up a whole (every unit falls in exactly one category). It is good for seeing which category is biggest or for comparing one slice with half or a quarter of the circle, but small differences between similar slices are hard to see. A bar chart is almost always better for comparing categories.
Twenty-five students were asked how they get to school. The responses were: Bus, Car, Walk, Bus, Bike, Car, Bus, Walk, Car, Bus, Bus, Car, Walk, Bike, Car, Bus, Walk, Car, Bus, Bike, Car, Walk, Bus, Car, Bus. Make a frequency table and a relative frequency table, and write a claim supported by the data.
Tally each category: Bus 9, Car 8, Walk 5, Bike 3 (the total is \(9+8+5+3=25\)). Each relative frequency is the count divided by 25.
| Transportation | Frequency | Relative frequency | Percent |
|---|---|---|---|
| Bus | 9 | \(9/25=0.36\) | 36% |
| Car | 8 | \(8/25=0.32\) | 32% |
| Walk | 5 | \(5/25=0.20\) | 20% |
| Bike | 3 | \(3/25=0.12\) | 12% |
| Total | 25 | 1.00 | 100% |
Claim, in context: "Riding the bus is the most common way these 25 students get to school (9 of 25, or 36%), and together the bus and the car account for 68% of the students." The claim names the group and the variable and cites the numbers that justify it.
A school surveyed 80 juniors about their favorite school lunch: pizza 28, burrito 20, salad 12, sandwich 14, other 6. Find the relative frequencies and the pie-chart angles.
The relative frequencies are \(28/80=0.35\), \(20/80=0.25\), \(12/80=0.15\), \(14/80=0.175\) and \(6/80=0.075\), which add to 1. The pie-chart angles are \(0.35(360^\circ)=126^\circ\), \(90^\circ\), \(54^\circ\), \(63^\circ\) and \(27^\circ\), which add to \(360^\circ\). The bar chart above uses the counts as heights, and the pie chart uses these angles. A claim the graphs support: "Pizza and burritos together are the favorite of \(48/80=60\%\) of the juniors surveyed."
Comparing categorical data for two or more groups
Frequency and relative frequency tables, bar charts and pie charts can all be used to compare two or more data sets in terms of the same categorical variable. The key rule is to compare relative frequencies, not counts, whenever the groups have different sizes. Counts depend on how many students were asked as well as on how popular each lunch is.
The same lunch question was asked of 60 seniors. Their counts: pizza 18, burrito 21, salad 6, sandwich 9, other 6. Compare the lunch preferences of juniors (80 students) and seniors (60 students).
The relative frequencies for seniors are \(18/60=0.30\), \(21/60=0.35\), \(6/60=0.10\), \(9/60=0.15\) and \(6/60=0.10\) (they sum to 1).
| Lunch | Juniors (n = 80) | Seniors (n = 60) |
|---|---|---|
| Pizza | 0.350 | 0.300 |
| Burrito | 0.250 | 0.350 |
| Salad | 0.150 | 0.100 |
| Sandwich | 0.175 | 0.150 |
| Other | 0.075 | 0.100 |
A comparison that uses counts would say that more juniors than seniors chose pizza (28 compared with 18) and a nearly equal number chose burritos (20 and 21), but those counts mislead because there are 20 more juniors. Using relative frequencies: pizza is the favorite of juniors (35%) and burrito is the favorite of seniors (35%). A higher share of seniors than juniors prefer burritos (35% compared with 25%), and a smaller share of seniors prefer pizza (30% compared with 35%). In every sentence we named both groups and used a comparison word, as the exam expects.
A bar chart shows the number of customers who chose Plan A (48) and Plan B (52), but the vertical axis starts at 45. The Plan B bar looks more than twice as tall as the Plan A bar. Is the chart fair?
No. With the axis starting at 45 the visible heights are 3 and 7, a ratio of 7 to 3, while the counts differ by only \(52-48=4\) out of 100 customers. The bar heights represent the counts, so the axis must start at 0. Drawn correctly the two bars look nearly equal, which is what the data say.
- A frequency table gives counts; a relative frequency table gives proportions (count divided by the total). Percentages, relative frequencies, ratios and proportions carry the same information.
- A bar chart has one bar per category, height = count or relative frequency, axis starting at 0. A pie chart has one slice per category, area (angle) proportional to relative frequency, slices summing to 100%.
- To justify a claim, cite the counts or relative frequencies and name the group and variable.
- To compare groups of different sizes, compare relative frequencies, and write comparison sentences that name both groups.
- Of 40 customers, 14 ordered a latte, 11 drip coffee, 6 espresso, and 9 tea. Make a relative frequency table and state which drink is the most popular, with evidence.
Show answer
Relative frequencies: latte \(14/40=0.35\), drip \(11/40=0.275\), espresso \(6/40=0.15\), tea \(9/40=0.225\) (total 1.00). The latte is the most popular: 35% of the 40 customers ordered one, more than any other drink.
- In a survey of 200 people, 90 own a dog, 70 a cat, 10 a bird, 20 fish, and 10 another kind of pet. In a pie chart, what is the central angle for dogs and for cats?
Show answer
Dogs: \(90/200=0.45\), so \(0.45(360^\circ)=162^\circ\). Cats: \(70/200=0.35\), so \(126^\circ\). (Bird \(18^\circ\), fish \(36^\circ\), other \(18^\circ\); the five angles total \(360^\circ\).)
- Of 60 students surveyed, 15 said they would like a later start time. Write this result as a proportion, a percentage, and a ratio of "yes" to "no".
Show answer
Proportion \(15/60=0.25\); percentage 25%; 45 said no, so the ratio of yes to no is \(15:45=1:3\).
- In section 1, 24 of 40 students prefer morning classes. In section 2, 50 of 100 students prefer morning classes. A student says "more students in section 2 prefer mornings, so mornings are more popular in section 2." Evaluate this claim.
Show answer
The claim compares counts, but the sections have different sizes. In section 1, \(24/40=60\%\) prefer mornings; in section 2, \(50/100=50\%\). A larger share of section 1 prefers mornings, even though section 2 has more students who do.
- A bar chart shows two bars labeled 48 and 52 on an axis that begins at 45. Explain why this can mislead a reader and what should be changed.
Show answer
The bar heights should be proportional to the counts, but starting the axis at 45 makes the second bar look more than twice as tall as the first (7 against 3 units) even though the counts differ by about 8%. The axis should start at 0.
- A pie chart of how 120 students get to school has a slice for "bus" with a central angle of \(135^\circ\). How many students ride the bus?
Show answer
The slice is \(135/360=0.375\) of the circle, so \(0.375(120)=45\) students ride the bus.