Page 226 - Applied Statistics with R
P. 226
226 CHAPTER 11. CATEGORICAL PREDICTORS AND INTERACTIONS
If the two and three way interactions were not in the model, the whole “coeffi-
cient” would simply be
.
1
Thus, no matter the values of and , would determine the relationship
2
1
3
between (disp) and (mpg).
1
With the addition of the two-way interactions, now the “coefficient” would be
( + + ).
1
4 2
5 3
Now, changing (disp) has a different effect on (mpg), depending on the
1
values of and .
3
2
Lastly, adding the three-way interaction gives the whole “coefficient”
( + + + )
7 2 3
5 3
4 2
1
which is even more flexible. Now changing (disp) has a different effect on
1
(mpg), depending on the values of and , but in a more flexible way which
3
2
we can see with some more rearrangement. Now the “coefficient” in front of 3
in this “coefficient” is dependent on .
2
( + + ( + ) )
7 2
4 2
5
3
1
It is so flexible, it is becoming hard to interpret!
Let’s fit this three-way interaction model in R.
big_model = lm(mpg ~ disp * hp * domestic, data = autompg)
summary(big_model)
##
## Call:
## lm(formula = mpg ~ disp * hp * domestic, data = autompg)
##
## Residuals:
## Min 1Q Median 3Q Max
## -11.9410 -2.2147 -0.4008 1.9430 18.4094
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 6.065e+01 6.600e+00 9.189 < 2e-16 ***
## disp -1.416e-01 6.344e-02 -2.232 0.0262 *

