Page 179 - Applied Statistics with R
P. 179

9.5. SIMULATION                                                   179








                                                                                       60
                              60

                                                                                       50

                               40
                                                                                       40
                              y
                                20
                                                                                       30

                                 0                                                     20


                                                                            10
                                    2                                                  10
                                                                          8
                                       4
                                                                      6
                                           6                            x2             0
                                                                  4
                                         x1
                                                8
                                                             2
                                                     10







                      We then calculate


                                                  ̂
                                                               ⊤
                                                       ⊤
                                                   = (     ) −1       .
                      (beta_hat = C %*% t(X) %*% y)


                      ##          [,1]
                      ## x0   7.290735
                      ## x1 -2.282176
                      ## x2   5.843424

                      Notice that these values are the same as the coefficients found using lm() in R.
   174   175   176   177   178   179   180   181   182   183   184