require(glm2)
data(heart)
#======================================================
# Model with periodic non-convergence when glm is used
#======================================================
start.p <- sum(heart$Deaths) / sum(heart$Patients)
fit.glm <- glm(cbind(Deaths, Patients-Deaths) ~ factor(AgeGroup) + factor(Severity)
+ factor(Delay) + factor(Region), family = binomial(log),
start = c(log(start.p), -rep(1e-4, 8)), data = heart, trace = TRUE, maxit = 100)
fit.logbin <- logbin(formula(fit.glm), data = heart, trace = 1)
## (Note that convergence may be sped up by specifying mono = c(1,2))
summary(fit.logbin)
#=============================
# Model with interaction term
#=============================
heart$AgeSev <- 10 * heart$AgeGroup + heart$Severity
fit.logbin.int <- logbin(cbind(Deaths, Patients-Deaths) ~ factor(AgeSev)
+ factor(Delay) + factor(Region), data = heart, trace = 1, maxit = 100000)
summary(fit.logbin.int)
vcov(fit.logbin.int)
confint(fit.logbin.int)
summary(predict(fit.logbin.int, type = "response"))
anova(fit.logbin, fit.logbin.int, test = "Chisq")
Run the code above in your browser using DataLab