tmpar <- par(mfrow=c(1,2),mar=c(3.1,3.1,0,0)) mplot(predict(leprosy.fit),resid(leprosy.fit),group=leprosy$drug, xlab="(a) predicted",ylab="residual") mtext("(a) predicted",1,2) mtext("residual",2,2) abline(0,0,lty=2) tmp <- data.frame(y=resid(leprosy.fit),x=predict(leprosy.fit),drug=leprosy$drug) mlines(tmp$x,predict(aov(y~x*drug,tmp)),group=tmp$drug) legend(13,9,c("A","B","C"),lty=1:3) se.bar(17,-3,std.dev(leprosy.fit),cap="SD") mplot(leprosy$x,leprosy$y,group=leprosy$drug,xlab="",ylab="") mtext("(b) before",1,2) mtext("after",2,2) leprosy.ifit <- aov(y~x*drug,leprosy) mlines(leprosy$x,predict(leprosy.ifit),group=leprosy$drug) tmp <- mean(leprosy$x) abline(v=tmp,lty=4) points(rep(tmp,3),predict(leprosy.ifit,data.frame(drug=levels(leprosy$drug), x=rep(tmp,3))),pch=18) points(tapply(leprosy$x,leprosy$drug,mean),tapply(leprosy$y,leprosy$drug,mean), pch=5) se.bar(18,5,std.dev(leprosy.ifit),cap="SD") par(tmpar)