Page 288 - Applied Statistics with R
P. 288

288                             CHAPTER 13. MODEL DIAGNOSTICS


                                 ##
                                 ## Call:
                                 ## lm(formula = y ~ ., data = lev_ex_1)
                                 ##
                                 ## Coefficients:
                                 ## (Intercept)            x1            x2
                                 ##        8.875       -1.375         4.625

                                 Notice the large changes in the coefficients. Also notice that each of the coef-
                                 ficients has changed in some way. Note that the leverages of the points would
                                 not have changed, as we have not modified any of the    values.
                                 Now let’s see what happens to these coefficients when we modify the y value of
                                 the point with the lowest leverage.

                                 which.min(hatvalues(lev_fit))


                                 ## 4
                                 ## 4

                                 lev_ex[which.min(hatvalues(lev_fit)),]


                                 ##   x1 x2   y
                                 ## 4  7   3 14


                                 We see that the original y value is 14. We’ll again create a copy of the data,
                                 and modify this point to have a y value of 30.

                                 lev_ex_2 = lev_ex
                                 lev_ex_2$y[4] = 30
                                 lm(y ~ ., data = lev_ex_2)


                                 ##
                                 ## Call:
                                 ## lm(formula = y ~ ., data = lev_ex_2)
                                 ##
                                 ## Coefficients:
                                 ## (Intercept)            x1            x2
                                 ##          5.7         -0.7           4.4


                                 This time despite a large change in the y value, there is only small change in
                                 the coefficients. Also, only the intercept has changed!
   283   284   285   286   287   288   289   290   291   292   293