Page 400 - Applied Statistics with R
P. 400

400    CHAPTER 16. VARIABLE SELECTION AND MODEL BUILDING


                                 summary(hipcenter_mod_forw_aic)$adj.r.squared



                                 ## [1] 0.6533055

                                 summary(hipcenter_mod_forw_bic)$adj.r.squared


                                 ## [1] 0.6282374


                                                                                2
                                 We can compare the two selected models’ Adjusted    as well as their LOOCV
                                 RMSE The results are very similar to those using backwards selection, although
                                 the models are not exactly the same.

                                 calc_loocv_rmse(hipcenter_mod)


                                 ## [1] 44.44564


                                 calc_loocv_rmse(hipcenter_mod_forw_aic)


                                 ## [1] 37.62516

                                 calc_loocv_rmse(hipcenter_mod_forw_bic)



                                 ## [1] 37.2511


                                 16.2.3   Stepwise Search

                                 Stepwise search checks going both backwards and forwards at every step. It
                                 considers the addition of any variable not currently in the model, as well as the
                                 removal of any variable currently in the model.
                                 Here we perform stepwise search using AIC as our metric. We start with
                                 the model hipcenter ~ 1 and search up to hipcenter ~ Age + Weight +
                                 HtShoes + Ht + Seated + Arm + Thigh + Leg. Notice that at many of the
                                 steps, some row begin with -, while others begin with +.

                                 hipcenter_mod_both_aic = step(
                                   hipcenter_mod_start,
                                   scope = hipcenter ~ Age + Weight + HtShoes + Ht + Seated + Arm + Thigh + Leg,
                                   direction = "both")
   395   396   397   398   399   400   401   402   403   404   405