You are on page 1of 29

Displaying and Describing

Categorical Data
Summarizing categorical data

Two-way tables

Relationships between categorical variables

Marginal distributions

Conditional distributions

Simpsons paradox

Summary of Categories
Count
Each category has a number of occurrences (frequency
tables)
Percentages are useful (relative frequency tables)

Sex

Count

Percentage

Male

157

46.4%

Female

181

53.6%

Total

338

100%

Two Categories
What is the relationship between two
categories?
Cross-classification table is a good
summary (contingency tables or two-way
Freshman
Sophomor Junior
Senior(+) Row
tables)
Male

43

Femal
e
Column
Totals

Totals

67

30

17

157

48

62

25

46

181

91

129

55

63

338

Column
Percentages
F

Sp

43

67

SR

30

17

47% 52% 55% 27%

48 62
25
46
53% 48% 45% 73%
91

129

Row
Percentages

55

63

100% 100% 100% 100%

157

46%

181
54%

338

Sp

43
27%

48
27%

67

SR

30

17

157

43% 19% 11% 100%

62

25

46

181

34% 14% 25% 100%

91

129

55

63

27%

38%

16%

19%

338

Which way is better?


There is a basic asymmetry to many
problems.
Explanatory variable
Predictor, cause, available variable

Response variable
Predicted, effect, interesting variable

Visualize Categorical Data


Give a clear picture of what the data
contain
Emphasize differences (or similarities)
Bar graphs and pie charts are usually best
Many varieties, actual form of the graph
depends on the use
Height of bar or size of pie slice shows the
frequency or percentage for each category
(area principle)
What is the graph communicating?

Bar Graph

Year in School

For 2 variables use multiple


columns

Or the other way around

My Pet Peeves
Graphs should
Be clear
Allow comparisons
Tell a story
Graphs should not
Have uninformative aspects
Obscure

Arrrgh!

Arrrgh! Arrrgh!

Wouldnt it just be simpler?

USA Today Snapshots

Pie Charts

Or

Allows clear comparisons

What is wrong with this


picture?

Constructing Bar and Pie


Charts
1. Define categories for variables of
interest
2. Determine the appropriate measure for
each category

For pie charts, the value assigned is the proportion


of the total for all categories

3. Develop the chart

For pie charts, the size of the slice is proportional to


value and the sum must equal 100%

More examples

Bar charts can also be displayed with vertical bars

Number of
days read

Frequency

44

24

18

16

20

22

26

30

Total

200

Pie Chart Example


Investment
Percentage
Type

Current Investment
Portfolio

Amount

(in thousands $)

Stocks
46.5
42.27
Bonds
32.0
CD
15.5
Savings
16.0
14.55
Total

Saving
s
15%

110

29.09
14.09

CD
14%

Stock
s
42%

100

Qualitative variables
Must equal 100%

Bond
s
29%

Percentages
are rounded
to the
nearest
percent

Marginal distributions
We can look at each categorical variable separately in a twoway table by studying the row totals and the column totals.
They represent the marginal distributions, expressed in
counts or percentages (They are written as if in a margin.)

2000 U.S. census

The marginal distributions can then be displayed on separate bar


graphs, typically expressed as percents instead of raw counts. Each
graph represents only one of the two variables, completely ignoring the
second one.

Conditional distribution
Music and wine purchase decision

What is the relationship between type of


music played in supermarkets and type of
wine purchased?
We want to compare the conditional distributions of the
response variable (wine purchased) for each value of the
explanatory variable (music played). Therefore, we
calculate column percents.
Calculations: When no music was played, there
were 84 bottles of wine sold. Of these, 30 were
French wine.
30/84 = 0.357 35.7% of the wine sold was
French when no music was played.
We calculate the column
conditional percents similarly
for each of the nine cells in
the table:

30 = 35.7%
84
cell total .
=
column total

For every two-way table, there are


two sets of possible conditional
distributions.
Does background
music in supermarkets
influence customer
purchasing decisions?

Wine purchased for each


kind of music played
(column percents)

Music played for


each kind of wine
purchased (row

Simpsons paradox

An association or comparison that holds for all of several groups


can reverse direction when the data are combined (aggregated)
to form a single group. This reversal is called Simpsons
paradox.
Example: Hospital
death rates

On the surface,
Hospital B would
seem to have a
better record.

But once patient


condition is taken
into account, we
see that hospital A
has in fact a better
record for both patient conditions (good and poor).
Here, patient condition was the lurking variable.

You might also like