options(digits=4) rats=read.csv("S:/webpages/~renaes/Data/weight gain.csv",header=T) attach(rats) boxplot(gain~type+level,main="Boxplot of Weight Gain in Rats by Food Type and Level") rat.fit=lm(gain~type*level) anova(rat.fit) interaction.plot(level,type,gain, type="b",main="Interaction Plot of \nWeight Gain in Rats by Food Type and Level") # checking assumptions: res=rstudent(rat.fit) pred=fitted.values(rat.fit) hist(res,main='Histogram of Residuals') plot(pred,res,main='Predicted vs. Residuals') abline(0,0); abline(-2,0,col='red'); abline(2,0,col='red') qqnorm(res,xlim=c(-3,3),ylim=c(-3,3)); qqline(res)