Chapter 11: Code and Figures

R Code

All verbatim chunk codes used in the Chapter are available in dismap.R

Figures

Figure 11.2

Click on figure to go back to Chapter gallery. Please see preceeding chunks for values not set in this chunk (dismap-011.R).

library(epitools)

CISMR<-pois.exact(nc$Observed, nc$Expected)

plot(1,1, type="n", xlim=c(1,100), ylim=c(0,9),
  main= "Confidence intervals of the SMR",
  xlab="County", ylab="Relative Risk", xaxt="n")
abline(h=1, lty=2)

for(i in 1:100)
{
        if(CISMR$lower[i]>1 )
        {
                col<-gray(.4)
		lty<-2
                text(i, CISMR$upper[i]+.31, nc$NAME[i],
                srt=90, col=gray(.4), cex=.85)
        }
        else
        {
                col<-"black"
		lty<-1
        }

        lines(c(i,i), c(CISMR$lower[i],CISMR$upper[i]), col=col, lty=lty)
        points(i, nc$SMR[i], pch=18, col=col)
}