model.bact1 <- glm(y ~ trt * week, family = binomial('logit'), data = bacteria) model.bact2 <- glm(y ~ trt + week, family = binomial('logit'), data = bacteria) model.bact3 <- glm(y ~ week, family = binomial('logit'), data = bacteria) anova(model.bact1, model.bact2, model.bact3, test = 'LRT') # Analysis of Deviance Table # Model 1: y ~ trt * week # Model 2: y ~ trt + week # Model 3: y ~ week # Resid. Df Resid. Dev Df Deviance Pr(>Chi) # 1 214 203.12 # 2 216 203.81 -2 -0.6854 0.70984 # 3 218 210.91 -2 -7.1026 0.02869 * #Based on these results, we select model #2 as the best candidate to model these data.