oop <-
options(na.action = "na.fail")
# Based on "example(predict.glm)", with one number changed to create
# overdispersion
budworm <- data.frame(
ldose = rep(0:5, 2), sex = factor(rep(c("M", "F"), c(6, 6))),
numdead = c(10, 4, 9, 12, 18, 20, 0, 2, 6, 10, 12, 16))
budworm$SF = cbind(numdead = budworm$numdead,
numalive = 20 - budworm$numdead)
budworm.lg <- glm(SF ~ sex*ldose, data = budworm, family = binomial)
(chat <- deviance(budworm.lg) / df.residual(budworm.lg))
dredge(budworm.lg, rank = "QAIC", chat = chat)
dredge(budworm.lg, rank = "AIC")
if (FALSE) {
# A 'hacked' constructor for quasibinomial family object that allows for
# ML estimation
hacked.quasibinomial <- function(...) {
res <- quasibinomial(...)
res$aic <- binomial(...)$aic
res
}
QAIC(update(budworm.lg, family = hacked.quasibinomial), chat = chat)
}
options(oop)
Run the code above in your browser using DataLab