Interaction

Example Let's have a look at the pain reliever dataset. In

headache.fun(1)

we draw the scatterplot of Time by Dose and the boxplots of Time by Sex and Time by BPQuan. There seems to be a non-linear relationship of Time by Dose, which of course makes very good sense (?). The other two variables don't seem to have a big effect on Time.

headache.fun(2)

fits a model quadratic in Dose and linear in Sex and BPQuan. The diagnostic plots all appear ok. Looking at the t-tests we see that Dose is highly significant, Sex is borderline non-significant and BPQuan is highly non-significant. Using stepwise regression

headache(3)

we find a model quadratic in Dose and with Sex but without BPQuan.

Is this it? Actually no. In

headache.fun(4)

we draw the residual vs. fits plot but with each observation identified by its blood pressure (L, M or H). We also add the fitted lines of the residuals vs. fits, separate for the three blood pressure groups. It is clear that there is still some structure in this plot, indicating a lack of fit of this model.

Let's include the interaction terms in our model. In

headache.fun(5)

we do this and again draw the residual vs fits plot as above.
This seems to help some although it is not perfect. However, graphs can sometimes be tricky to read, see

headache.fun(6)

Now we have a rather complicated model. In

headache.fun(7)

we use stepwise regression again to simplify it if possible. We find a model quadratic in Dose and with all the terms except the threeway interaction. Notice that this model has R2=94%, a big improvement over the model with Dose and Sex which had R2=83%.