if (FALSE) {
library(agridat)
data(beall.webworms)
dat <- beall.webworms
# Match Beall table 1
# with(dat, table(y,trt))
libs(lattice)
histogram(~y|trt, data=dat, layout=c(1,4), as.table=TRUE,
main="beall.webworms")
# Visualize Beall table 6. Block effects may exist, but barely.
libs(desplot)
grays <- colorRampPalette(c("white","#252525"))
desplot(dat, y ~ col*row,
col.regions=grays(10),
at=0:10-0.5,
out1=block, out2=trt, num=trt, flip=TRUE, # aspect unknown
main="beall.webworms (count of worms)")
# Following plot suggests interaction is needed
# with(dat, interaction.plot(spray, lead, y))
# Try the models of Kosma et al, Table 1.
# Poisson model
m1 <- glm(y ~ block + spray*lead, data=dat, family="poisson")
logLik(m1) # -1497.719 (df=16)
# Negative binomial model
# libs(MASS)
# m2 <- glm.nb(y ~ block + spray*lead, data=dat)
# logLik(m2) # -1478.341 (df=17)
# # Conway=Maxwell-Poisson model (takes several minutes)
# libs(spaMM)
# # estimate nu parameter
# m3 <- fitme(y ~ block + spray*lead, data=dat, family = COMPoisson())
# logLik(m3) # -1475.999
# # Kosma logLik(m3)=-1717 seems too big. Typo? Different model?
}
Run the code above in your browser using DataLab