Page 101 - Applied Statistics with R
P. 101

7.2. LEAST SQUARES APPROACH                                       101


                      min(cars$speed) < 21 & 21 < max(cars$speed)



                      ## [1] TRUE



                                                ̂    = −17.58 + 3.93 × 21



                      beta_0_hat + beta_1_hat * 21


                      ## [1] 65.00149


                      Lastly, we can make a prediction for the stopping distance of a car traveling at
                      50 miles per hour. This is considered extrapolation as 50 is not an observed
                      value of    and is outside data range. We should be less confident in predictions
                      of this type.

                      range(cars$speed)


                      ## [1]   4 25


                      range(cars$speed)[1] < 50 & 50 < range(cars$speed)[2]


                      ## [1] FALSE




                                                ̂    = −17.58 + 3.93 × 50


                      beta_0_hat + beta_1_hat * 50



                      ## [1] 179.0413


                      Cars travel 50 miles per hour rather easily today, but not in the 1920s!
                                                                ̂
                      This is also an issue we saw when interpreting    = −17.58, which is equivalent
                                                                0
                      to making a prediction at    = 0. We should not be confident in the estimated
                      linear relationship outside of the range of data we have observed.
   96   97   98   99   100   101   102   103   104   105   106