Page 225 - Applied Statistics with R
P. 225
11.5. BUILDING LARGER MODELS 225
11.5 Building Larger Models
Now that we have seen how to incorporate categorical predictors as well as
interaction terms, we can start to build much larger, much more flexible models
which can potentially fit data better.
Let’s define a “big” model,
= + + + + + + + + .
2 2
3 3
0
1 1
6 2 3
7 1 2 3
4 1 2
5 1 3
Here,
• is mpg.
• is disp.
1
• is hp.
2
• is domestic, which is a dummy variable we defined, where 1 is a do-
3
mestic vehicle.
First thing to note here, we have included a new term which is a three-
1 2 3
way interaction. Interaction terms can be larger and larger, up to the number
of predictors in the model.
Since we are using the three-way interaction term, we also use all possible two-
way interactions, as well as each of the first order (main effect) terms. This is
the concept of a hierarchy. Any time a “higher-order” term is in a model, the
related “lower-order” terms should also be included. Mathematically their inclu-
sion or exclusion is sometimes irrelevant, but from an interpretation standpoint,
it is best to follow the hierarchy rules.
Let’s do some rearrangement to obtain a “coefficient” in front of .
1
= + + + + ( + + + ) + .
1
6 2 3
4 2
5 3
7 2 3
1
2 2
0
3 3
Specifically, the “coefficient” in front of is
1
( + + + ).
1
7 2 3
5 3
4 2
Let’s discuss this “coefficient” to help us understand the idea of the flexibility
of a model. Recall that,
• is the coefficient for a first order term,
1
• and are coefficients for two-way interactions,
5
4
• is the coefficient for the three-way interaction.
7

