Page 349 - Applied Statistics with R
P. 349

14.2. PREDICTOR TRANSFORMATION                                    349




                                              Simulated Quadratic Data


                             120



                             80
                        y    60

                             40
                             20

                             0

                                 0         1         2          3         4         5

                                                          x



                      par(mfrow = c(1, 2))

                      plot(fitted(quad_fit), resid(quad_fit), col = "grey", pch = 20,
                            xlab = "Fitted", ylab = "Residuals", main = "Fitted versus Residuals")
                      abline(h = 0, col = "darkorange", lwd = 2)

                      qqnorm(resid(quad_fit), main = "Normal Q-Q Plot", col = "darkgrey")
                      qqline(resid(quad_fit), col = "dodgerblue", lwd = 2)




                                 Fitted versus Residuals              Normal Q-Q Plot

                          10                                 10

                          5                                  5
                        Residuals  0                      Sample Quantiles  0


                          -5                                 -5

                          -10                                -10

                            0   20  40  60  80  100  120      -3  -2   -1  0   1    2   3
                                        Fitted                        Theoretical Quantiles
   344   345   346   347   348   349   350   351   352   353   354