1.2 Graphical Tools
for Data Exploration 15Body weight (unit=100kg)
Brain (unit=100g)
0
10
20
30
40
50
0 200 400 600 800
A: Linear scales
Body weight (unit=100kg)
Brain (unit=100g)
0.01
0.1
1
10
100
0.001
0.01
0.1
1
10
100
1000
B: Logarithmic scales
Figure 1.5 Brain weight v
ersus body weight, for 28 animals that vary greatly in
size. Panel A has untransformed scales, while Panel B has logarithmic scales, on
both axes.
Simplified code is:
measles <- DAAG::measles
## Panel A
plot(log10(measles), xlab="", ylim=log10 (c(1,5000∗540)),
ylab=" Deaths; Population", yaxt="n")
ytiks1 <- c(1, 10, 100, 1000); ytiks2
<- c(1000000, 5000000)
## London population in thousands
londonpop <-ts(c(1088,1258,1504,1778,2073,2491,2921,3336,3881,
4266,4563,4541,4498,4408), start=1801, end=1931, deltat=10)
points(log10(londonpop∗600),
pch=16, cex=.5)
abline(h=log10(ytiks1), lty = 2, col =
"gray", lwd = 2)
abline(h=log10(ytiks2∗0.5), lty = 2, col =
"gray", lwd = 2)
axis(2, at=log10(ytiks1), labels=paste(ytiks1), lwd=0,
lwd.ticks=1)
axis(2, at=log10(ytiks2∗0.5), labels=paste(ytiks2),
tcl=0.3,
hadj=0, lwd=0, lwd.ticks=1)
## Panel B
plot(window(measles, start=1840, end=1882), ylim=c (0,
4600), yaxt="n")
points(londonpop, pc
h=16, cex=0.5)
axis(2, at=(0:4)∗ 1000, labels=paste(0:4), las=2)
F
or details of the data, and commentary, see Guy (1882), Stocks (1942), and
Senn (2003) where interest was in the comparison with smallpox mortality. The
population estimates (londonpop) are from Mitchell (1988).
1.2.3 Visualizing Relationships Between Pairs of Variables
Patterns and relationships linking multiple variables are a primary focus of data
analysis. The following example is concerned with the relationship between two
variables and illustrates an important question that often arises: What is the ap-
propriate scale?
Figures 1.5AandBplot brain weight (g) against body weight (kg), for 28 animals.
Panel A indicates that the distributions of data values are highly positively skew,
on both axes, but is otherwise unhelpful. Panel B’s logarithmic scales spread points
out more evenly, and the graph tells a clearer story. Note that, on both axes, tick
https://doi.org/10.1017/9781009282284.002 Published online by Cambridge University Press