aGraphs

advertisement
Displaying data with graphs
Objectives
Picturing Distributions with Graphs

Individuals and variables

Two types of data: categorical and quantitative

Ways to chart categorical data: bar graphs and pie charts

Ways to chart quantitative data: histograms, dotplots and stemplots

Interpreting histograms

Time plots
Individuals and variables
Individuals are the objects described by a set of data. Individuals may
be people, animals, or things.

Freshmen, 6-week-old babies, golden retrievers, fields of corn, cells
A variable is any characteristic of an individual. A variable can take
different values for different individuals.

Age, gender, blood pressure, blood type, leaf length, flower color
Two types of variables
A variable can be either

quantitative
Something that can be counted or measured for each individual. We can
then report the average of all individuals measured.

Age (in years), blood pressure (in mm Hg), leaf length (in cm)
or

categorical
Something that falls into one of several categories. We can then report
the count or proportion of individuals in each category.

Gender (male, female), blood type (A, B, AB, O), flower color (white, yellow, red)
How do you decide if a variable is categorical or quantitative?
Ask:

What are the n individuals examined (in the sample or population)?

What is being recorded about those n individuals?

Is that a number ( quantitative) or a statement ( categorical)?
Categorical
Each individual is
assigned to one of
several categories
Quantitative
Each individual is
attributed a
numerical value
Individuals in sample
DIAGNOSIS
AGE AT DEATH
Patient A
Heart disease
56
Patient B
Stroke
70
Patient C
Stroke
75
Patient D
Lung cancer
60
Patient E
Heart disease
80
Patient F
Accident
73
Patient G
Diabetes
69
Ways to chart categorical data
When a variable is categorical, the data in the graph can be ordered any
way we want (alphabetical, by increasing value, by year, by personal
preference, etc.).
Most common ways to graph categorical data:

Bar graphs
Each category is represented by a bar that represents the counts of
individuals in that category or their relative frequency (percent of all
categories shown).

Pie charts
Each category is represented by a slice of the whole pie that represents
its relative frequency.
Peculiarity: The slices must represent the parts of one coherent whole.
Example: Top 10 causes of death in the United States, 2001
Rank Causes of death
Counts
Percent of
top 10s
Percent of
total
deaths
1 Heart disease
700,142
37%
29%
2 Cancer
553,768
29%
23%
3 Cerebrovascular
163,538
9%
7%
4 Chronic respiratory
123,013
6%
5%
5 Accidents
101,537
5%
4%
6 Diabetes mellitus
71,372
4%
3%
7 Flu and pneumonia
62,034
3%
3%
8 Alzheimer’s disease
53,852
3%
2%
9 Kidney disorders
39,480
2%
2%
32,238
2%
1%
10 Septicemia
All other causes
629,967
26%
For each individual who died in the United States in 2001, we record what was
the cause of death. The table above is a summary of that information.
Bar graph
Counts (x1000)
Here the bar’s height shows the count of individuals for that particular category.
800
700
600
500
400
300
200
100
0
Top 10 causes of death in the U.S., 2001
The number of individuals
who died of an accident in
2001 is approximately
100,000.
r
s
s
e
ia
s
ry
rs
ia
ts
a
r
s
e
u
l
n
o
t
e
n
e
s
t
a
m
o
li
e
d
l
c
a
e
a
e
cu
r
r
d
e
n
m
s
s
e
i
o
i
a
u
tic
ci
a
s
p
s
i
m
d
i
e
v
c
p
s
C
d
s
n
s
o
e
e
'
A
td
r
r
r
e
p
r
y
S
t
b
e
e
e
ic
e
&
ea
n
r
m
b
n
i
e
H
id
o
lu
ia
e
r
C
F
K
h
D
h
z
C
Al
ov
ce
rs
on
ic
as
cu
la
r
re
sp
ira
D
to
ia
be
ry
te
s
m
Fl
el
u
lit
us
&
pn
eu
m
on
H
ea
ia
rt
di
se
Ki
as
dn
es
ey
di
so
rd
er
s
Se
pt
ic
em
ia
C
hr
C
an
s
se
nt
di
se
a
Ac
ci
de
er
's
eb
r
ei
m
C
er
Al
zh
Counts (x1000)
eb
r
is
e
ov
ce
rs
es
as
C
an
rt
d
as
cu
on
la
ic
r
re
sp
ira
to
ry
Ac
ci
D
de
ia
nt
be
s
te
s
m
Fl
el
u
lit
&
us
pn
Al
eu
zh
m
ei
on
m
ia
er
's
di
Ki
se
dn
as
ey
e
di
so
rd
er
s
Se
pt
ic
em
ia
C
hr
C
er
H
ea
Counts (x1000)
800
700
600
500
400
300
200
100
0
Top 10 causes of death in the U.S., 2001
Bar graph sorted by rank
 Easy to analyze
800
700
600
500
400
300
200
100
0
Sorted alphabetically
 Much less useful
Pie chart
Each slice represents a piece of one whole.
The size of a slice depends on what percent of the whole this category represents.
Percent of people dying from
top 10 causes of death in the U.S., 2001
Make sure
all percents
add up to 100.
Percent of deaths from top 10 causes
Make sure the
labels match
the data.
Percent of
deaths from
all causes
Common ways to chart quantitative data

Histograms
This is a summary graph for a single variable. Histograms are useful to
understand the pattern of variability in the data, especially for large data sets.

Dotplots and stemplots
These are graphs for a the raw data. They are useful to describe the pattern
of variability in the data, especially for small data sets.

Line graphs: time plots
Use them when there is a meaningful sequence, like time. The line
connecting the points helps emphasize any change over time.

Other graphs to display numerical summaries (see chapter 2)
Histograms
The range of values that a
variable can take is divided
into equal-size intervals.
The histogram shows the
number of individual data
points that fall in each
interval.
The first column represents all states with a percent Hispanic in their
population between 0% and 4.99%. The height of the column shows how
many states (27) have a percent Hispanic in this range.
The last column represents all states with a percent Hispanic between 40%
and 44.99%. There is only one such state: New Mexico, at 42.1% Hispanic.
How to create a histogram
It is an iterative process—try and try again.
What bin size should you use?

Not too many bins with either 0 or 1 counts

Not overly summarized that you lose all the information

Not so detailed that it is no longer summary
 Rule of thumb: Start with 5 to10 bins.
Look at the distribution and refine your bins.
(There isn’t a unique or “perfect” solution.)
Same data set
Not
summarized
enough
Too summarized
Interpreting histograms
When describing a quantitative variable, we look for the overall pattern
and for striking deviations from that pattern. We can describe the overall
pattern of a histogram by its shape, center, and spread.
Histogram with a line connecting
each column  too detailed
Histogram with a smoothed curve
highlighting the overall pattern of
the distribution
Most common distribution shapes
A symmetric distribution
the right and left sides of the histogram are
approximately mirror images of each other
Left skewed
Right skewed
the left side extends
much farther out than
the right side.
the right side (side with larger
values) extends much farther
out than the left side.
Symmetric
Skewed to the right
Complex,
bimodal
distribution
Not all distributions have a simple shape
(especially with few observations).
Outliers
An important kind of deviation is an outlier. Outliers are observations
that lie outside the overall pattern of a distribution. Always look for
outliers and try to explain them.
Fairly symmetric but 2
states clearly don’t belong
to the main trend
 Alaska and Florida have
unusual percents of elderly
in their population.
Alaska
A large gap in the
distribution is typically a
sign of an outlier.
Florida
Stemplots
How to make a stemplot:
STEM
LEAVES
1) Separate each observation into a stem,
consisting of all but the final (rightmost) digit,
and a leaf, which is that remaining final digit.
Stems may have as many digits as needed, but
each leaf contains only a single digit.
2) Write the stems in a vertical column with the
smallest value at the top, and draw a vertical line
at the right of this column.
3) Write each leaf in the row to the right of its stem,
in increasing order out from the stem.
Original data: 9, 9, 22, 32, 33, 39, 39, 42, 49, 52, 58, 70
State
Percent
Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida
Georgia
Hawaii
Idaho
Illinois
Indiana
Iowa
Kansas
Kentucky
Louisiana
Maine
Maryland
Massachusetts
Michigan
Minnesota
Mississippi
Missouri
Montana
Nebraska
Nevada
NewHampshire
NewJersey
NewMexico
NewYork
NorthCarolina
NorthDakota
Ohio
Oklahoma
Oregon
Pennsylvania
RhodeIsland
SouthCarolina
SouthDakota
Tennessee
Texas
Utah
Vermont
Virginia
W ashington
W estVirginia
W isconsin
W yoming
1.5
4.1
25.3
2.8
32.4
17.1
9.4
4.8
16.8
5.3
7.2
7.9
10.7
3.5
2.8
7
1.5
2.4
0.7
4.3
6.8
3.3
2.9
1.3
2.1
2
5.5
19.7
1.7
13.3
42.1
15.1
4.7
1.2
1.9
5.2
8
3.2
8.7
2.4
1.4
2
32
9
0.9
4.7
7.2
0.7
3.6
6.4
Step 1:
Sort the
data
State
Percent
Maine
W estVirginia
Vermont
NorthDakota
Mississippi
SouthDakota
Alabama
Kentucky
NewHampshire
Ohio
Montana
Tennessee
Missouri
Louisiana
SouthCarolina
Arkansas
Iowa
Minnesota
Pennsylvania
Michigan
Indiana
W isconsin
Alaska
Maryland
NorthCarolina
Virginia
Delaware
Oklahoma
Georgia
Nebraska
W yoming
Massachusetts
Kansas
Hawaii
W ashington
Idaho
Oregon
RhodeIsland
Utah
Connecticut
Illinois
NewJersey
NewYork
Florida
Colorado
Nevada
Arizona
Texas
California
NewMexico
0.7
0.7
0.9
1.2
1.3
1.4
1.5
1.5
1.7
1.9
2
2
2.1
2.4
2.4
2.8
2.8
2.9
3.2
3.3
3.5
3.6
4.1
4.3
4.7
4.7
4.8
5.2
5.3
5.5
6.4
6.8
7
7.2
7.2
7.9
8
8.7
9
9.4
10.7
13.3
15.1
16.8
17.1
19.7
25.3
32
32.4
42.1
Percent of Hispanic residents
in each of the 50 states
Step 2:
Assign the
values to
stems and
leaves
Stemplots versus histograms
Stemplots are quick and dirty histograms that can easily be done by
hand, therefore, very convenient for back of the envelope calculations.
However, they are rarely found in scientific or laymen publications.
IMPORTANT NOTE:
Your data are the way they are.
Do not try to force them into a
particular shape.
It is a common misconception
that if you have a large enough
data set, the data will eventually
turn out nice and symmetrical.
Dotplots
Like stemplots, dotplots show the entire raw data and are well suited for
describing small data sets.
Each individual in the data set is shown as one dot on the horizontal
axis representing the variable’s scale. Individuals with identical value
are superimposed vertically.
Skin healing rates of 18 anesthetized newts. Each newt is shown as a dot. The
plot indicates no obvious outlier.
Line graphs: time plots
Time always goes on the
horizontal (x) axis. The
variable of interest goes on
the vertical (y) axis.
Look for an overall trend
and cyclical patterns.
Overall upward trend in pricing over time: It could simply be reflecting inflation
trends or more fundamental changes in this industry.
Regular pattern of yearly variations: Seasonal variations in fresh orange pricing
most likely due to similar seasonal variations in the production.
Scales matter
Death rates from cancer (US, 1945-95)
How you stretch the axes and choose your
scales can give a different impression.
Death rate (per thousand)
Death rates from cancer (US, 1945-95)
250
Death rate (per
thousand)
250
200
150
100
200
150
100
50
50
0
1940
1950
1960
1970
1980
1990
0
1940
2000
1960
1980
2000
Years
Years
Death rates from cancer (US, 1945-95)
250
Death rates from cancer (US, 1945-95)
220
Death rate (per thousand)
Death rate (per thousand)
200
150
100
50
0
1940
1960
Years
1980
2000
A picture is worth a
thousand words,
200
BUT
180
160
there is nothing like hard
numbers.
 Look at the scales.
140
120
1940
1960
1980
Years
2000
Download