Page 342 - Applied Statistics with R
P. 342

342                              CHAPTER 14. TRANSFORMATIONS


                                 plot(salary ~ years, data = initech, col = "grey", pch = 20, cex = 1.5,
                                      main = "Salaries at Initech, By Seniority")
                                 abline(initech_fit, col = "darkorange", lwd = 2)















                                                      Salaries at Initech, By Seniority



                                       250000



                                   salary  150000





                                       50000



                                                    5         10         15         20        25

                                                                   years









                                 par(mfrow = c(1, 2))

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

                                 qqnorm(resid(initech_fit), main = "Normal Q-Q Plot", col = "darkgrey")
                                 qqline(resid(initech_fit), col = "dodgerblue", lwd = 2)
   337   338   339   340   341   342   343   344   345   346   347