Page 347 - Applied Statistics with R
P. 347

14.2. PREDICTOR TRANSFORMATION                                    347




                                              Simulated Quadratic Data


                             120



                             80
                        y    60

                             40
                             20

                             0

                                 0         1         2          3         4         5

                                                          x



                      par(mfrow = c(1, 2))

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

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




                                 Fitted versus Residuals              Normal Q-Q Plot


                          20                                 20
                          10                                 10
                        Residuals  0                      Sample Quantiles  0



                          -10                                -10
                          -20                                -20

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