Page 319 - Applied Statistics with R
P. 319

14.2. PREDICTOR TRANSFORMATION                                    319







                                 95%
                             -80


                        log-Likelihood  -120  -160








                             -200


                                -2           -1           0            1            2

                                                          λ



                      Using the Box-Cox method, we see that    = 0 is both in the interval, and
                      extremely close to the maximum, which suggests a transformation of the form


                                                      log(  ).

                      So the Box-Cox method justifies our previous choice of a log transform!


                      14.2     Predictor Transformation


                      In addition to transformation of the response variable, we can also consider
                      transformations of predictor variables. Sometimes these transformations can
                      help with violation of model assumptions, and other times they can be used to
                      simply fit a more flexible model.


                      str(autompg)


                      ## 'data.frame':     383 obs. of   9 variables:
                      ##   $ mpg     : num  18 15 18 16 17 15 14 14 14 15 ...
                      ##   $ cyl     : Factor w/ 3 levels "4","6","8": 3 3 3 3 3 3 3 3 3 3 ...
                      ##   $ disp    : num  307 350 318 304 302 429 454 440 455 390 ...
                      ##   $ hp      : num  130 165 150 150 140 198 220 215 225 190 ...
                      ##   $ wt      : num  3504 3693 3436 3433 3449 ...
   314   315   316   317   318   319   320   321   322   323   324