Академический Документы
Профессиональный Документы
Культура Документы
Graphics
23.07.2014
Housekeeping
I Contact details
Office auckland.ac.nz hours
Steffen Klaere 303.219 s.klaere 10:0012:00, Thu
Alan Lee 303S.265 aj.lee 10:3012:00, Tue+Thu
I Class representatives
Course aucklanduni.ac.nz
?? 330 ??
?? 762 ??
I One variable
Aim: explore distribution of values
Plots: Histograms, Kernel density estimators, QQ plots
I Two variables
Aim: explore relationship of variables
Both continuous: Scatter plot
One of each: Side-by-side box plots or violin plots
Both categorical: Mosaic plots (see Chapter 5)
yt
t = log(yt ) log(yt1 ) = log
yt1
Suppose we have the data (t , t = 2, . . . , 6980), in an R vector,
diff.in.logs
# Draw histogram
hist(diff.in.logs,nclass=100,freq=FALSE)
# Add density estimates
lines(density(diff.in.logs),col="blue",lwd=2)
# Add fitted normal density
xvec <- seq(-0.2,0.1,length=100)
lines(xvec,dnorm(xvec,mean=mean(diff.in.logs),
sd=sd(diff.in.logs)),col="red",lwd=2)
Histogram of diff.in.logs
80
60
Density
40
20
0
diff.in.logs
Histogram of diff.in.logs
80
60
Density
40
20
0
diff.in.logs
Normal QQ Plot
Normal QQ Plot
qqnorm(diff.in.logs)
0.05
qqline(diff.in.logs,lwd=3)
Normal data? NO
I
0.00
Sample Quantiles
0.05
than normal
I Plotted points are below line
0.10
600
500
Weight (grams)
400
300
0 10 20 30 40 50 60
Time (days)
Rats! More sophisticated visualisation
Growth rates for rats
600
500
Weight (grams)
400
300
0 20 40 60
Time (days)
Rats! And more sophistication
0 20 40 60 0 20 40 60
300
300
0 20 40 60 0 20 40 60
Time (days)
Rats! And more sophistication
0 20 40 60 0 20 40 60 0 20 40 60 0 20 40 60
600
500
400
300
0 20 40 60 0 20 40 60 0 20 40 60 0 20 40 60
Time (days)
One continuous and one categorical variable
I Side-by-side boxplots
The fever of mice
39.0
38.5
38.0
body temperature
LOESS Smoothing
37.5
37.0
36.5
36.0
00:00 01:45 03:30 05:15 07:00 08:45 10:30 12:15 14:00 15:45 17:30 19:15 21:00 22:45
day time
More than two variables
I If all variables are continuous, we can explore the relationships
between them using a pairs plot
I If we have three variables, a rotating plot is a very useful tool
I Example: Cherry trees
Pairs Plot for Cherry Trees
65 70 75 80 85
20
18
16
diameter
14
12
10
8
85
80
height
75
70
65
70
60
50
volume
40
30
20
10
8 10 12 14 16 18 20 10 20 30 40 50 60 70
3D Rotating plots
70
60
50
Volume
40
30
20
10
8 10 12 14 16 18 20
Diameter
plot(diameter,volume,
plot3d(cherry.df)
data=cherry.df)
Dynamic motion
I reg3d(cherry.df,wire=TRUE)
I By dynamically changing the angle
of view, we get a better impression
of the 3-dimensional structure of
the data
I Dynamic graphics is a very
powerful tool
Fast Normal Slow
Pause/Resume
A powerful idea: Coplots
65 70 75 80 85 65 70 75 80 85
70
60
50
40
30
20
volume
10
70
60
50
40
30
20
10
65 70 75 80 85
height
Concluding Lecture 2