For example, Gelman 6, I believe that you first need to aggregate the crime. The frisk_with_noise.dat file contains 900 observations, one record for each ethnic group, a plot for each crime (75 * 3 * 4 = 900). But the example in chapter 6 shows n = 225 (75 * 3). So Ben's code extension with something like this brings you a little closer to replicating output:
library(arm) # for display() function X <- read.table("frisk_with_noise.dat",skip=6,header=TRUE) names(X)[3] <- "arrests" X <- aggregate(cbind(stops, arrests) ~ precinct + eth, data=X, sum) fit.1 <- glm(stops~1,family=poisson,offset=log(arrests),data=X, subset=arrests>0) display(fit.1)
But, as the note at the top of the frisk_with_noise.dat file notes, noise is added, so the results cannot be accurately reproduced.
source share