## EXAMPLE 1:
data(epi.SClip)
obs <- epi.SClip$cases; pop <- epi.SClip$population
est <- epi.empbayes(obs, pop)
crude.p <- ((obs) / (pop)) * 100000
crude.r <- rank(crude.p)
ebay.p <- ((obs + est[4]) / (pop + est[3])) * 100000
dat.df01 <- data.frame(rank = c(crude.r, crude.r),
Method = c(rep("Crude", times = length(crude.r)),
rep("Empirical Bayes", times = length(crude.r))),
est = c(crude.p, ebay.p))
## Scatter plot showing the crude and empirical Bayes adjusted lip cancer
## incidence rates as a function of district rank for the crude lip
## cancer incidence rates:
if (FALSE) {
library(ggplot2)
ggplot(dat = dat.df01, aes(x = rank, y = est, colour = Method)) +
theme_bw() +
geom_point() +
scale_x_continuous(name = "District rank",
breaks = seq(from = 0, to = 60, by = 10),
labels = seq(from = 0, to = 60, by = 10),
limits = c(0,60)) +
scale_y_continuous(limits = c(0,30), name = "Lip cancer incidence rates
(cases per 100,000 person years)")
}
Run the code above in your browser using DataLab