Chapter 8 Interactions in ANOVA and Regression

Main effects are the effects of a single variable on the response variable. The interaction between two variables is the effect of one variable on the response variable, conditional on the value of the other variable. We use the “weightgain” dataset from the “MASS” package. The dataset contains the weight gain of rats fed different food (beef vs. cereal) and diets (high-protein vs. low-protein). We aim to answer the following questions:

  • Is there a difference in weight gain between the two diets? (about main effects)
  • Is there a difference in weight gain between the two foods? (about main effects)
  • Is the difference between low and high protein greater for the beef diet than for the cereal diet? (about interaction)

We visualize the interaction where Y-axis represents the weight gain and X-axis notes beef and cereal. There are two different lines representing high protein and low protein.

# install.packages("HSAUR")
library(HSAUR)
data("weightgain", package = "HSAUR")
# Create and display an interaction plot
wg <- weightgain # Copy the dataset into a new object
interaction.plot(x.factor=wg$source,trace.factor=wg$type, response=wg$weightgain)

The endpoints of the two lines are the means of each group. There are no points in between beef and cereal. The two lines are not parallel, which suggests the possibility that the effect of food source on weight gain dependent on (has interaction with) the type of diet. Specifically, rats provided with high-protein beef diet gain much more weights over a low-protein beef diet. Whereas rats provided with high-protein cereal diet gain only slightly more weights over a low-protein cereal diet. We need ANOVA to test whether the interaction is significant.