############################################################ ############################################################ ############################################################ ############################################################ rats <- read.table("rats.dat",header=T) rats plot(time ~ treat + poison,data=rats) interaction.plot(rats$treat,rats$poison,rats$time) interaction.plot(rats$poison,rats$treat,rats$time) interaction.model <- lm(time ~ treat + poison + treat:poison,data=rats) summary(interaction.model) # how to test all of the interaction terms at once? noi.model <- lm(time ~ treat + poison,data=rats) anova(interaction.model,noi.model) plot(interaction.model$fitted.values,rstudent(interaction.model)) plot(noi.model$fitted.values,rstudent(noi.model)) # okay, no significant interaction summary(noi.model) # how to test all of the poison terms at once? nop.model <- lm(time ~ treat,data=rats) anova(noi.model,nop.model) # also: not.model <- lm(time ~ poison,data=rats) anova(not.model,noi.model) # so each of the main effects is significant, though the interaction is # not. This allows us to test the main effects independent of one # another. TukeyHSD(aov(time ~ treat,data=rats)) plot(time~treat,data=rats) TukeyHSD(aov(time ~ poison,data=rats)) plot(time~poison,data=rats) ## another try: int.model <- lm( log(time) ~ poison + treat + poison:treat,data=rats) no.int.model <- lm( log(time) ~ poison + treat,data=rats) anova(int.model,no.int.model) plot(int.model$fitted.values,rstudent(int.model)) no.poi.model <- lm( log(time) ~ treat,data=rats) anova(no.poi.model,no.int.model) no.trt.model <- lm( log(time) ~ poison,data=rats) anova(no.trt.model,no.int.model) TukeyHSD(aov(log(time)~poison,data=rats)) plot(log(time)~poison,data=rats) plot(log(time)~treat,data=rats) rats