# # Load the "Nassau County Racial Imbalance" Data # downloaded from # http://www.stat.washington.edu/handcock/594/Data/lischool.RData # load("lischool.RData") # # Convert proportion of white # pwhite <- lischool[,"WHITE"] / lischool[,"TOTAL"] # pdf(file = "FigLec7.2.pdf",width=10.5,height=7.5,horiz=T) par(mfrow=c(1,2)) # library(logspline) # hist(pwhite, type='n', probability=T, main="Nassau County Schools\n Alternative estimates", ylim=c(0,5.5), xlab = "Proportion of White Students", ylab = "Probability") lines(density(pwhite, bw="SJ")) rug(pwhite) # yl <- logspline.fit(pwhite, lbound = 0, ubound = 1) gpdf <- dlogspline(seq(0,1,length=1000), fit=yl) lines(x = seq(0,1,length=1000), y = 1000*gpdf/(sum(gpdf)), lty=2) # # add a legend # legend(x=c(0,0),y=c(3.5,3.5),lty=1:2, legend=c("Sheather-Jones","default log-spline fit")) # hist(pwhite, type='n', probability=T, main="Nassau County Schools\n Alternative estimates", ylim=c(0,5.5), xlab = "Proportion of White Students", ylab = "Probability") lines(density(pwhite, bw="SJ")) rug(pwhite) # yl <- logspline.fit(pwhite, lbound = 0, ubound = 1, nknots=12, delete=F) gpdf <- dlogspline(seq(0,1,length=1000), fit=yl) lines(x = seq(0,1,length=1000), y = 1000*gpdf/(sum(gpdf)), lty=2) # # add a legend # legend(x=c(0,0),y=c(3.5,3.5),lty=1:2, legend=c("Sheather-Jones","less smooth log-spline fit"))