Page 361 - Applied Statistics with R
P. 361

14.2. PREDICTOR TRANSFORMATION                                    361





                                                             0.6

                          3.5                                0.4
                                                             0.2
                        log(mpg)  3.0                     Residuals  0.0

                                                             -0.2
                          2.5                                -0.4
                                                             -0.6

                               4.0    4.5     5.0    5.5       2.4  2.6  2.8  3.0  3.2  3.4  3.6
                                       log(hp)                            Fitted


                      big_model = lm(mpg ~ disp * hp * domestic, data = autompg)

                      qqnorm(resid(big_model), col = "darkgrey")
                      qqline(resid(big_model), col = "dodgerblue", lwd = 2)




                                                   Normal Q-Q Plot



                             15  10
                        Sample Quantiles  5  0









                             -10  -5


                                -3       -2       -1      0        1       2        3

                                                   Theoretical Quantiles


                      bigger_model = lm(log(mpg) ~ disp * hp * domestic +
                                      I(disp ^ 2) + I(hp ^ 2), data = autompg)
                      summary(bigger_model)
   356   357   358   359   360   361   362   363   364   365   366