Budworms <- data.frame(Logdose = rep(0:5, 2), Sex = factor(rep(c("M", "F"), each = 6)), Dead = c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16)) Budworms$Alive <- 20 - Budworms$Dead xyplot(Dead/20 ~ I(2^Logdose), Budworms, groups = Sex, panel = panel.superpose, xlab = "Dose", ylab = "Fraction dead", key = list(text = list(c("Females:", "Males:")), points = Rows(trellis.par.get("superpose.symbol"), 1:2), lines = Rows(trellis.par.get("superpose.line"), 1:2), columns = 2, transparent = T), type="b") bud.1 <- glm(cbind(Dead, Alive) ~ Sex*Logdose, binomial, Budworms, trace=T, eps=1.0e-9) bud.0 <- update(bud.1, .~.-Sex:Logdose) attach(Budworms) plot(2^Logdose, Dead/20, xlab = "Dose", ylab = "Fraction dead", type = "n") text(2^Logdose, Dead/20, c("+","o")[Sex], col = 5, cex = 1.25) newdat <- expand.grid(Logdose = seq(-0.1, 5.1, 0.1), Sex = levels(Sex)) newdat$Pr0 <- predict(bud.0, newdat, type = "response") newdat$Pr1 <- predict(bud.1, newdat, type = "response") ditch <- newdat$Logdose == 5.1 | newdat$Logdose < 0 newdat[ditch, ] <- NA attach(newdat) lines(2^Logdose, Pr1, col=4, lty = 4) lines(2^Logdose, Pr0, col=3) key(0,1,text = list(c("Females", "Males")), transparent = T, points = list(pch = c("+", "o"), col = 5)) key(0, 0.8, text = list(c("bud1", "bud0")), lines = list(lty = c(4, 1), col = c(4, 3)), transparent = T) detach("newdat") detach("Budworms")