\begin{Schunk}
\begin{Sinput}
 xvals <- seq(0,80,length.out=1000)
 chisquare <- dchisq(xvals, df=50)
 plot(xvals, chisquare, type="l", xlab=expression(chi^2), ylab="probability density",  ylim=c(0,0.10), main="")
 critVal <- qchisq(0.05, df=50, lower.tail=F)
 chiAtCrit <- dchisq(critVal, df=50)
 lines(c(critVal,critVal), c(0, chiAtCrit), lty=4)
 abline(h=0, lwd=0.5)
 mtext(expression(hat(k)), side=1, line=1, at=critVal)
 xvals <- seq(critVal, 80, length.out=50)
 polygon( x=c(xvals, xvals[50], sort(xvals,decreasing=T), critVal), 
        y=c(dchisq(xvals,df=50), 0, rep(0,50), 0), col=gray(.90)) 
 text(74, 0.018, expression(area == 1-F(hat(k))))
\end{Sinput}
\end{Schunk}
