Mike Livermore – CSI 773 – Week 3 Assignment – Density Plots – September 2010
1.1: Fixed 1.11 Plot
text(.5,.75,'Density Estimate Construction',adj=c(.5,.5),cex=1.5,col="Blue")
2.1: Precipitation Dot plot
2.2: Density Plt
2.3: Plot
# Find a decent smoothing parameter for the data
bw = 4
bw
# Try several different kernels.
# The chosen smoothing parameter may be poor for some of them
kernels = eval(formals(density.default)$kernel)
windows(width=8,height=10)
panels = panelLayout(nrow=1,ncol=1,
leftMar=1.5, rightMar=1,
topMar=.4, bottomMar=1,
rowSep=.1)
# Default gaussian kernel, used to find a range
ans = density(precip,bw=bw)
rx = range(ans$x)
ry = range(ans$y)
ry[1] = 0
ry[2] = ry[2]*1.10 # pad by 10%
for (i in 1:1){
panelSelect(panels,i,1)
panelScale(rx,ry)
panelFill()
axis(side=1,tck=1,labels=F,col='white',las=2,lwd=1)
axis(side=4,tck=0,mgp=c(2,.3,0),las=2)
axis(side=2,tck=1,labels=F,col="white",las=2,lwd=)
lines(density(precip, bw = bw, kern = kernels[i]),lwd=2)
mtext(side=2,line=1,las=2,kernels[i],adj=1)
panelOutline()
if(i==1)mtext(side=3,line=1.5,"Densities Based on Gaussian Kernels",cex=1.2,adj=.5)
if(i==1){
axis(side=1,tck=0,mgp=c(2,.3,0))
mtext(side=1,line=1.5,"Average Annual Precipitation in Inches")
}
}
##End
2.4: Density Plot with Jittered
3: Density Plot with Labels
4: Plot and answers to four questions
Q1) Does a shape1 parameter smaller than 1 make left tail go up or down? UP
Q2) Does a shape1 parameter large than 1 make the make the left tail go up or down? DOWN
Q3) Does a shape2 parameter smaller than 1 make right tail go up or down? UP
Q4) Does a shape2 parameter larger than 1 make the make the right tail go up or down? DOWN