Page 209 - Applied Statistics with R
P. 209

11.2. INTERACTIONS                                                209








                                                                               Foreign
                                                                               Domestic
                             40



                        mpg  30

                             20



                             10

                                    100          200           300          400

                                                         disp


                      We see that these lines fit the data much better, which matches the result of
                      our tests.
                      So far we have only seen interaction between a categorical variable (domestic)
                      and a numerical variable (disp). While this is easy to visualize, since it allows
                      for different slopes for two lines, it is not the only type of interaction we can use
                      in a model. We can also consider interactions between two numerical variables.
                      Consider the model,

                                            =    +       +       +          +   ,
                                                   1 1
                                              0
                                                                3 1 2
                                                         2 2
                      where
                         •    is mpg, the fuel efficiency in miles per gallon,
                         •    is disp, the displacement in cubic inches,
                            1
                         •    is hp, the horsepower, in foot-pounds per second.
                            2
                      How does mpg change based on disp in this model? We can rearrange some
                      terms to see how.


                                            =    + (   +       )   +       +   
                                                                  2 2
                                                             1
                                               0
                                                    1
                                                         3 2
                      So, for a one unit increase in    (disp), the mean of    (mpg) increases    +      ,
                                                                                    1
                                                1
                                                                                        3 2
                      which is a different value depending on the value of    (hp)!
                                                                     2
   204   205   206   207   208   209   210   211   212   213   214