tests/testthat/_snaps/stepaic-both-output.md

output from stepAIC both direction regression is as expected when adding and removing variables

Code
  ols_step_both_aic(model, progress = TRUE)
Output
  Stepwise Selection Method 
  -------------------------

  Candidate Terms:

  1. x1 
  2. x2 
  3. x3 
  4. x4 
  5. x5 
  6. x6


  Variables Added/Removed:

  => x6 added 
  => x1 added 
  => x3 added 
  => x2 added 
  => x6 removed 
  => x4 added

  No more variables to be added or removed.


                                   Stepwise Summary                                 
  --------------------------------------------------------------------------------
  Step    Variable         AIC          SBC          SBIC         R2       Adj. R2 
  --------------------------------------------------------------------------------
   0      Base Model    56988.482    57004.289       228.318    0.00000    0.00000 
   1      x6 (+)        33473.297    33497.007    -23285.069    0.69145    0.69143 
   2      x1 (+)        32931.758    32963.372    -23826.833    0.69972    0.69969 
   3      x3 (+)        31912.722    31952.239    -24845.827    0.71466    0.71462 
   4      x2 (+)        29304.296    29351.717    -27453.243    0.74958    0.74953 
   5      x6 (-)        29302.317    29341.835    -27455.223    0.74958    0.74954 
   6      x4 (+)        29300.814    29348.235    -27456.724    0.74962    0.74957 
  --------------------------------------------------------------------------------

  Final Model Output 
  ------------------

                            Model Summary                           
  -----------------------------------------------------------------
  R                       0.866       RMSE                   0.503 
  R-Squared               0.750       MSE                    0.253 
  Adj. R-Squared          0.750       Coef. Var           6430.859 
  Pred R-Squared          0.749       AIC                29300.814 
  MAE                     0.402       SBC                29348.235 
  -----------------------------------------------------------------
   RMSE: Root Mean Square Error 
   MSE: Mean Square Error 
   MAE: Mean Absolute Error 
   AIC: Akaike Information Criteria 
   SBC: Schwarz Bayesian Criteria

                                     ANOVA                                    
  ---------------------------------------------------------------------------
                   Sum of                                                    
                  Squares           DF    Mean Square        F          Sig. 
  ---------------------------------------------------------------------------
  Regression    15163.528            4       3790.882    14966.061    0.0000 
  Residual       5064.705        19995          0.253                        
  Total         20228.233        19999                                       
  ---------------------------------------------------------------------------

                                    Parameter Estimates                                   
  ---------------------------------------------------------------------------------------
        model      Beta    Std. Error    Std. Beta      t        Sig      lower    upper 
  ---------------------------------------------------------------------------------------
  (Intercept)    -0.005         0.004                 -1.496    0.135    -0.012    0.002 
           x1     0.255         0.003        0.362    84.140    0.000     0.249    0.261 
           x3     0.253         0.003        0.356    82.604    0.000     0.247    0.259 
           x2     0.249         0.003        0.346    80.544    0.000     0.243    0.255 
           x4    -0.007         0.004       -0.007    -1.872    0.061    -0.014    0.000 
  ---------------------------------------------------------------------------------------
Code
  ols_step_both_aic(model, details = TRUE)
Output
  Stepwise Selection Method 
  -------------------------

  Candidate Terms:

  1. x1 
  2. x2 
  3. x3 
  4. x4 
  5. x5 
  6. x6


  Step     => 0 
  Model    => y ~ 1 
  AIC      => 56988.48

  Initiating stepwise selection...

                           Table: Adding New Variables                           
  ------------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2  
  ------------------------------------------------------------------------------
  x1            1    43073.160    43096.870    -13686.868    0.50136     0.50133 
  x2            1    43561.884    43585.595    -13198.216    0.48902     0.48900 
  x3            1    43267.194    43290.904    -13492.863    0.49650     0.49647 
  x4            1    56989.595    57013.305       227.932      4e-05      -1e-05 
  x5            1    56990.439    57014.149       228.776    0.00000      -5e-05 
  x6            1    33473.297    33497.007    -23285.069    0.69145     0.69143 
  ------------------------------------------------------------------------------

  Step     => 1 
  Added    => x6 
  Model    => y ~ x6 
  AIC      => 33473.3

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x1            1    32931.758    32963.372    -23826.833    0.69972    0.69969 
  x2            1    33033.295    33064.909    -23725.325    0.69819    0.69816 
  x3            1    32959.771    32991.385    -23798.829    0.69930    0.69927 
  x4            1    33470.717    33502.331    -23288.023    0.69152    0.69149 
  x5            1    33475.275    33506.889    -23283.467    0.69145    0.69142 
  -----------------------------------------------------------------------------

  Step     => 2 
  Added    => x1 
  Model    => y ~ x6 + x1 
  AIC      => 32931.76

                       Table: Removing Existing Variables                       
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x6            1    43073.160    43096.870    -13686.868    0.50136    0.50133 
  x1            1    33473.297    33497.007    -23285.069    0.69145    0.69143 
  -----------------------------------------------------------------------------

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x2            1    32025.492    32065.010    -24733.099    0.71305    0.71301 
  x3            1    31912.722    31952.239    -24845.827    0.71466    0.71462 
  x4            1    32928.035    32967.552    -23830.887    0.69980    0.69976 
  x5            1    32933.735    32973.252    -23825.189    0.69972    0.69967 
  -----------------------------------------------------------------------------

  Step     => 3 
  Added    => x3 
  Model    => y ~ x6 + x1 + x3 
  AIC      => 31912.72

                       Table: Removing Existing Variables                       
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x6            1    34923.269    34954.883    -21835.862    0.66828    0.66825 
  x1            1    32959.771    32991.385    -23798.829    0.69930    0.69927 
  x3            1    32931.758    32963.372    -23826.833    0.69972    0.69969 
  -----------------------------------------------------------------------------

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x2            1    29304.296    29351.717    -27453.243    0.74958    0.74953 
  x4            1    31908.533    31955.954    -24850.258    0.71475    0.71470 
  x5            1    31914.523    31961.944    -24844.270    0.71467    0.71461 
  -----------------------------------------------------------------------------

  Step     => 4 
  Added    => x2 
  Model    => y ~ x6 + x1 + x3 + x2 
  AIC      => 29304.3

                       Table: Removing Existing Variables                       
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x6            1    29302.317    29341.835    -27455.223    0.74958    0.74954 
  x1            1    32080.424    32119.941    -24678.188    0.71226    0.71222 
  x3            1    32025.492    32065.010    -24733.099    0.71305    0.71301 
  x2            1    31912.722    31952.239    -24845.827    0.71466    0.71462 
  -----------------------------------------------------------------------------

  Step     => 5 
  Removed  => x6 
  Model    => y ~ x1 + x3 + x2 
  AIC      => 29302.32

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x4            1    29300.814    29348.235    -27456.724    0.74962    0.74957 
  x5            1    29304.253    29351.673    -27453.287    0.74958    0.74953 
  -----------------------------------------------------------------------------

  Step     => 6 
  Added    => x4 
  Model    => y ~ x1 + x3 + x2 + x4 
  AIC      => 29300.81

                       Table: Removing Existing Variables                       
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x1            1    35361.098    35400.615    -21398.670    0.66097    0.66092 
  x3            1    35170.915    35210.432    -21588.789    0.66418    0.66413 
  x2            1    34918.668    34958.185    -21840.951    0.66839    0.66834 
  x4            1    29302.317    29341.835    -27455.223    0.74958    0.74954 
  -----------------------------------------------------------------------------

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x5            1    29302.751    29358.075    -27454.786    0.74962    0.74956 
  -----------------------------------------------------------------------------


  No more variables to be added or removed.

  Variables Selected:

  => x1 
  => x3 
  => x2 
  => x4


                                   Stepwise Summary                                 
  --------------------------------------------------------------------------------
  Step    Variable         AIC          SBC          SBIC         R2       Adj. R2 
  --------------------------------------------------------------------------------
   0      Base Model    56988.482    57004.289       228.318    0.00000    0.00000 
   1      x6 (+)        33473.297    33497.007    -23285.069    0.69145    0.69143 
   2      x1 (+)        32931.758    32963.372    -23826.833    0.69972    0.69969 
   3      x3 (+)        31912.722    31952.239    -24845.827    0.71466    0.71462 
   4      x2 (+)        29304.296    29351.717    -27453.243    0.74958    0.74953 
   5      x6 (-)        29302.317    29341.835    -27455.223    0.74958    0.74954 
   6      x4 (+)        29300.814    29348.235    -27456.724    0.74962    0.74957 
  --------------------------------------------------------------------------------

  Final Model Output 
  ------------------

                            Model Summary                           
  -----------------------------------------------------------------
  R                       0.866       RMSE                   0.503 
  R-Squared               0.750       MSE                    0.253 
  Adj. R-Squared          0.750       Coef. Var           6430.859 
  Pred R-Squared          0.749       AIC                29300.814 
  MAE                     0.402       SBC                29348.235 
  -----------------------------------------------------------------
   RMSE: Root Mean Square Error 
   MSE: Mean Square Error 
   MAE: Mean Absolute Error 
   AIC: Akaike Information Criteria 
   SBC: Schwarz Bayesian Criteria

                                     ANOVA                                    
  ---------------------------------------------------------------------------
                   Sum of                                                    
                  Squares           DF    Mean Square        F          Sig. 
  ---------------------------------------------------------------------------
  Regression    15163.528            4       3790.882    14966.061    0.0000 
  Residual       5064.705        19995          0.253                        
  Total         20228.233        19999                                       
  ---------------------------------------------------------------------------

                                    Parameter Estimates                                   
  ---------------------------------------------------------------------------------------
        model      Beta    Std. Error    Std. Beta      t        Sig      lower    upper 
  ---------------------------------------------------------------------------------------
  (Intercept)    -0.005         0.004                 -1.496    0.135    -0.012    0.002 
           x1     0.255         0.003        0.362    84.140    0.000     0.249    0.261 
           x3     0.253         0.003        0.356    82.604    0.000     0.247    0.259 
           x2     0.249         0.003        0.346    80.544    0.000     0.243    0.255 
           x4    -0.007         0.004       -0.007    -1.872    0.061    -0.014    0.000 
  ---------------------------------------------------------------------------------------

output from stepSBC both direction regression is as expected when adding and removing variables

Code
  ols_step_both_sbc(model, progress = TRUE)
Output
  Stepwise Selection Method 
  -------------------------

  Candidate Terms:

  1. x1 
  2. x2 
  3. x3 
  4. x4 
  5. x5 
  6. x6


  Variables Added/Removed:

  => x6 added 
  => x1 added 
  => x3 added 
  => x2 added 
  => x6 removed

  No more variables to be added or removed.


                                   Stepwise Summary                                 
  --------------------------------------------------------------------------------
  Step    Variable         AIC          SBC          SBIC         R2       Adj. R2 
  --------------------------------------------------------------------------------
   0      Base Model    56988.482    57004.289       228.318    0.00000    0.00000 
   1      x6 (+)        33473.297    33497.007    -23285.069    0.69145    0.69143 
   2      x1 (+)        32931.758    32963.372    -23826.833    0.69972    0.69969 
   3      x3 (+)        31912.722    31952.239    -24845.827    0.71466    0.71462 
   4      x2 (+)        29304.296    29351.717    -27453.243    0.74958    0.74953 
   5      x6 (-)        29302.317    29341.835    -27455.223    0.74958    0.74954 
  --------------------------------------------------------------------------------

  Final Model Output 
  ------------------

                            Model Summary                           
  -----------------------------------------------------------------
  R                       0.866       RMSE                   0.503 
  R-Squared               0.750       MSE                    0.253 
  Adj. R-Squared          0.750       Coef. Var           6431.262 
  Pred R-Squared          0.749       AIC                29302.317 
  MAE                     0.402       SBC                29341.835 
  -----------------------------------------------------------------
   RMSE: Root Mean Square Error 
   MSE: Mean Square Error 
   MAE: Mean Absolute Error 
   AIC: Akaike Information Criteria 
   SBC: Schwarz Bayesian Criteria

                                     ANOVA                                    
  ---------------------------------------------------------------------------
                   Sum of                                                    
                  Squares           DF    Mean Square        F          Sig. 
  ---------------------------------------------------------------------------
  Regression    15162.641            3       5054.214    19951.084    0.0000 
  Residual       5065.592        19996          0.253                        
  Total         20228.233        19999                                       
  ---------------------------------------------------------------------------

                                    Parameter Estimates                                   
  ---------------------------------------------------------------------------------------
        model      Beta    Std. Error    Std. Beta      t        Sig      lower    upper 
  ---------------------------------------------------------------------------------------
  (Intercept)    -0.005         0.004                 -1.503    0.133    -0.012    0.002 
           x1     0.255         0.003        0.362    84.118    0.000     0.249    0.261 
           x3     0.253         0.003        0.356    82.597    0.000     0.247    0.259 
           x2     0.249         0.003        0.347    80.571    0.000     0.243    0.255 
  ---------------------------------------------------------------------------------------
Code
  ols_step_both_sbc(model, details = TRUE)
Output
  Stepwise Selection Method 
  -------------------------

  Candidate Terms:

  1. x1 
  2. x2 
  3. x3 
  4. x4 
  5. x5 
  6. x6


  Step     => 0 
  Model    => y ~ 1 
  SBC      => 57004.29

  Initiating stepwise selection...

                           Table: Adding New Variables                           
  ------------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2  
  ------------------------------------------------------------------------------
  x1            1    43073.160    43096.870    -13686.868    0.50136     0.50133 
  x2            1    43561.884    43585.595    -13198.216    0.48902     0.48900 
  x3            1    43267.194    43290.904    -13492.863    0.49650     0.49647 
  x4            1    56989.595    57013.305       227.932      4e-05      -1e-05 
  x5            1    56990.439    57014.149       228.776    0.00000      -5e-05 
  x6            1    33473.297    33497.007    -23285.069    0.69145     0.69143 
  ------------------------------------------------------------------------------

  Step     => 1 
  Added    => x6 
  Model    => y ~ x6 
  SBC      => 33497.01

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x1            1    32931.758    32963.372    -23826.833    0.69972    0.69969 
  x2            1    33033.295    33064.909    -23725.325    0.69819    0.69816 
  x3            1    32959.771    32991.385    -23798.829    0.69930    0.69927 
  x4            1    33470.717    33502.331    -23288.023    0.69152    0.69149 
  x5            1    33475.275    33506.889    -23283.467    0.69145    0.69142 
  -----------------------------------------------------------------------------

  Step     => 2 
  Added    => x1 
  Model    => y ~ x6 + x1 
  SBC      => 32963.37

                       Table: Removing Existing Variables                       
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x6            1    43073.160    43096.870    -13686.868    0.50136    0.50133 
  x1            1    33473.297    33497.007    -23285.069    0.69145    0.69143 
  -----------------------------------------------------------------------------

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x2            1    32025.492    32065.010    -24733.099    0.71305    0.71301 
  x3            1    31912.722    31952.239    -24845.827    0.71466    0.71462 
  x4            1    32928.035    32967.552    -23830.887    0.69980    0.69976 
  x5            1    32933.735    32973.252    -23825.189    0.69972    0.69967 
  -----------------------------------------------------------------------------

  Step     => 3 
  Added    => x3 
  Model    => y ~ x6 + x1 + x3 
  SBC      => 31952.24

                       Table: Removing Existing Variables                       
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x6            1    34923.269    34954.883    -21835.862    0.66828    0.66825 
  x1            1    32959.771    32991.385    -23798.829    0.69930    0.69927 
  x3            1    32931.758    32963.372    -23826.833    0.69972    0.69969 
  -----------------------------------------------------------------------------

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x2            1    29304.296    29351.717    -27453.243    0.74958    0.74953 
  x4            1    31908.533    31955.954    -24850.258    0.71475    0.71470 
  x5            1    31914.523    31961.944    -24844.270    0.71467    0.71461 
  -----------------------------------------------------------------------------

  Step     => 4 
  Added    => x2 
  Model    => y ~ x6 + x1 + x3 + x2 
  SBC      => 29351.72

                       Table: Removing Existing Variables                       
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x6            1    29302.317    29341.835    -27455.223    0.74958    0.74954 
  x1            1    32080.424    32119.941    -24678.188    0.71226    0.71222 
  x3            1    32025.492    32065.010    -24733.099    0.71305    0.71301 
  x2            1    31912.722    31952.239    -24845.827    0.71466    0.71462 
  -----------------------------------------------------------------------------

  Step     => 5 
  Removed  => x6 
  Model    => y ~ x1 + x3 + x2 
  SBC      => 29341.83

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x4            1    29300.814    29348.235    -27456.724    0.74962    0.74957 
  x5            1    29304.253    29351.673    -27453.287    0.74958    0.74953 
  -----------------------------------------------------------------------------


  No more variables to be added or removed.

  Variables Selected:

  => x1 
  => x3 
  => x2


                                   Stepwise Summary                                 
  --------------------------------------------------------------------------------
  Step    Variable         AIC          SBC          SBIC         R2       Adj. R2 
  --------------------------------------------------------------------------------
   0      Base Model    56988.482    57004.289       228.318    0.00000    0.00000 
   1      x6 (+)        33473.297    33497.007    -23285.069    0.69145    0.69143 
   2      x1 (+)        32931.758    32963.372    -23826.833    0.69972    0.69969 
   3      x3 (+)        31912.722    31952.239    -24845.827    0.71466    0.71462 
   4      x2 (+)        29304.296    29351.717    -27453.243    0.74958    0.74953 
   5      x6 (-)        29302.317    29341.835    -27455.223    0.74958    0.74954 
  --------------------------------------------------------------------------------

  Final Model Output 
  ------------------

                            Model Summary                           
  -----------------------------------------------------------------
  R                       0.866       RMSE                   0.503 
  R-Squared               0.750       MSE                    0.253 
  Adj. R-Squared          0.750       Coef. Var           6431.262 
  Pred R-Squared          0.749       AIC                29302.317 
  MAE                     0.402       SBC                29341.835 
  -----------------------------------------------------------------
   RMSE: Root Mean Square Error 
   MSE: Mean Square Error 
   MAE: Mean Absolute Error 
   AIC: Akaike Information Criteria 
   SBC: Schwarz Bayesian Criteria

                                     ANOVA                                    
  ---------------------------------------------------------------------------
                   Sum of                                                    
                  Squares           DF    Mean Square        F          Sig. 
  ---------------------------------------------------------------------------
  Regression    15162.641            3       5054.214    19951.084    0.0000 
  Residual       5065.592        19996          0.253                        
  Total         20228.233        19999                                       
  ---------------------------------------------------------------------------

                                    Parameter Estimates                                   
  ---------------------------------------------------------------------------------------
        model      Beta    Std. Error    Std. Beta      t        Sig      lower    upper 
  ---------------------------------------------------------------------------------------
  (Intercept)    -0.005         0.004                 -1.503    0.133    -0.012    0.002 
           x1     0.255         0.003        0.362    84.118    0.000     0.249    0.261 
           x3     0.253         0.003        0.356    82.597    0.000     0.247    0.259 
           x2     0.249         0.003        0.347    80.571    0.000     0.243    0.255 
  ---------------------------------------------------------------------------------------

output from stepSBIC both direction regression is as expected when adding and removing variables

Code
  ols_step_both_sbic(model, progress = TRUE)
Output
  Stepwise Selection Method 
  -------------------------

  Candidate Terms:

  1. x1 
  2. x2 
  3. x3 
  4. x4 
  5. x5 
  6. x6


  Variables Added/Removed:

  => x6 added 
  => x1 added 
  => x3 added 
  => x2 added 
  => x6 removed 
  => x4 added

  No more variables to be added or removed.


                                   Stepwise Summary                                 
  --------------------------------------------------------------------------------
  Step    Variable         AIC          SBC          SBIC         R2       Adj. R2 
  --------------------------------------------------------------------------------
   0      Base Model    56988.482    57004.289       228.318    0.00000    0.00000 
   1      x6 (+)        33473.297    33497.007    -23285.069    0.69145    0.69143 
   2      x1 (+)        32931.758    32963.372    -23826.833    0.69972    0.69969 
   3      x3 (+)        31912.722    31952.239    -24845.827    0.71466    0.71462 
   4      x2 (+)        29304.296    29351.717    -27453.243    0.74958    0.74953 
   5      x6 (-)        29302.317    29341.835    -27455.223    0.74958    0.74954 
   6      x4 (+)        29300.814    29348.235    -27456.724    0.74962    0.74957 
  --------------------------------------------------------------------------------

  Final Model Output 
  ------------------

                            Model Summary                           
  -----------------------------------------------------------------
  R                       0.866       RMSE                   0.503 
  R-Squared               0.750       MSE                    0.253 
  Adj. R-Squared          0.750       Coef. Var           6430.859 
  Pred R-Squared          0.749       AIC                29300.814 
  MAE                     0.402       SBC                29348.235 
  -----------------------------------------------------------------
   RMSE: Root Mean Square Error 
   MSE: Mean Square Error 
   MAE: Mean Absolute Error 
   AIC: Akaike Information Criteria 
   SBC: Schwarz Bayesian Criteria

                                     ANOVA                                    
  ---------------------------------------------------------------------------
                   Sum of                                                    
                  Squares           DF    Mean Square        F          Sig. 
  ---------------------------------------------------------------------------
  Regression    15163.528            4       3790.882    14966.061    0.0000 
  Residual       5064.705        19995          0.253                        
  Total         20228.233        19999                                       
  ---------------------------------------------------------------------------

                                    Parameter Estimates                                   
  ---------------------------------------------------------------------------------------
        model      Beta    Std. Error    Std. Beta      t        Sig      lower    upper 
  ---------------------------------------------------------------------------------------
  (Intercept)    -0.005         0.004                 -1.496    0.135    -0.012    0.002 
           x1     0.255         0.003        0.362    84.140    0.000     0.249    0.261 
           x3     0.253         0.003        0.356    82.604    0.000     0.247    0.259 
           x2     0.249         0.003        0.346    80.544    0.000     0.243    0.255 
           x4    -0.007         0.004       -0.007    -1.872    0.061    -0.014    0.000 
  ---------------------------------------------------------------------------------------
Code
  ols_step_both_sbic(model, details = TRUE)
Output
  Stepwise Selection Method 
  -------------------------

  Candidate Terms:

  1. x1 
  2. x2 
  3. x3 
  4. x4 
  5. x5 
  6. x6


  Step     => 0 
  Model    => y ~ 1 
  SBIC     => 230.9406

  Initiating stepwise selection...

                           Table: Adding New Variables                           
  ------------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2  
  ------------------------------------------------------------------------------
  x1            1    43073.160    43096.870    -13686.868    0.50136     0.50133 
  x2            1    43561.884    43585.595    -13198.216    0.48902     0.48900 
  x3            1    43267.194    43290.904    -13492.863    0.49650     0.49647 
  x4            1    56989.595    57013.305       227.932      4e-05      -1e-05 
  x5            1    56990.439    57014.149       228.776    0.00000      -5e-05 
  x6            1    33473.297    33497.007    -23285.069    0.69145     0.69143 
  ------------------------------------------------------------------------------

  Step     => 1 
  Added    => x6 
  Model    => y ~ x6 
  SBIC     => -23285.07

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x1            1    32931.758    32963.372    -23826.833    0.69972    0.69969 
  x2            1    33033.295    33064.909    -23725.325    0.69819    0.69816 
  x3            1    32959.771    32991.385    -23798.829    0.69930    0.69927 
  x4            1    33470.717    33502.331    -23288.023    0.69152    0.69149 
  x5            1    33475.275    33506.889    -23283.467    0.69145    0.69142 
  -----------------------------------------------------------------------------

  Step     => 2 
  Added    => x1 
  Model    => y ~ x6 + x1 
  SBIC     => -23826.83

                       Table: Removing Existing Variables                       
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x6            1    43073.160    43096.870    -13686.868    0.50136    0.50133 
  x1            1    33473.297    33497.007    -23285.069    0.69145    0.69143 
  -----------------------------------------------------------------------------

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x2            1    32025.492    32065.010    -24733.099    0.71305    0.71301 
  x3            1    31912.722    31952.239    -24845.827    0.71466    0.71462 
  x4            1    32928.035    32967.552    -23830.887    0.69980    0.69976 
  x5            1    32933.735    32973.252    -23825.189    0.69972    0.69967 
  -----------------------------------------------------------------------------

  Step     => 3 
  Added    => x3 
  Model    => y ~ x6 + x1 + x3 
  SBIC     => -24845.83

                       Table: Removing Existing Variables                       
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x6            1    34923.269    34954.883    -21835.862    0.66828    0.66825 
  x1            1    32959.771    32991.385    -23798.829    0.69930    0.69927 
  x3            1    32931.758    32963.372    -23826.833    0.69972    0.69969 
  -----------------------------------------------------------------------------

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x2            1    29304.296    29351.717    -27453.243    0.74958    0.74953 
  x4            1    31908.533    31955.954    -24850.258    0.71475    0.71470 
  x5            1    31914.523    31961.944    -24844.270    0.71467    0.71461 
  -----------------------------------------------------------------------------

  Step     => 4 
  Added    => x2 
  Model    => y ~ x6 + x1 + x3 + x2 
  SBIC     => -27453.24

                       Table: Removing Existing Variables                       
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x6            1    29302.317    29341.835    -27455.223    0.74958    0.74954 
  x1            1    32080.424    32119.941    -24678.188    0.71226    0.71222 
  x3            1    32025.492    32065.010    -24733.099    0.71305    0.71301 
  x2            1    31912.722    31952.239    -24845.827    0.71466    0.71462 
  -----------------------------------------------------------------------------

  Step     => 5 
  Removed  => x6 
  Model    => y ~ x1 + x3 + x2 
  SBIC     => -27455.22

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x4            1    29300.814    29348.235    -27456.724    0.74962    0.74957 
  x5            1    29304.253    29351.673    -27453.287    0.74958    0.74953 
  -----------------------------------------------------------------------------

  Step     => 6 
  Added    => x4 
  Model    => y ~ x1 + x3 + x2 + x4 
  SBIC     => -27456.72

                       Table: Removing Existing Variables                       
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x1            1    35361.098    35400.615    -21398.670    0.66097    0.66092 
  x3            1    35170.915    35210.432    -21588.789    0.66418    0.66413 
  x2            1    34918.668    34958.185    -21840.951    0.66839    0.66834 
  x4            1    29302.317    29341.835    -27455.223    0.74958    0.74954 
  -----------------------------------------------------------------------------

                           Table: Adding New Variables                          
  -----------------------------------------------------------------------------
  Predictor    DF       AIC          SBC          SBIC         R2       Adj. R2 
  -----------------------------------------------------------------------------
  x5            1    29302.751    29358.075    -27454.786    0.74962    0.74956 
  -----------------------------------------------------------------------------


  No more variables to be added or removed.

  Variables Selected:

  => x1 
  => x3 
  => x2 
  => x4


                                   Stepwise Summary                                 
  --------------------------------------------------------------------------------
  Step    Variable         AIC          SBC          SBIC         R2       Adj. R2 
  --------------------------------------------------------------------------------
   0      Base Model    56988.482    57004.289       228.318    0.00000    0.00000 
   1      x6 (+)        33473.297    33497.007    -23285.069    0.69145    0.69143 
   2      x1 (+)        32931.758    32963.372    -23826.833    0.69972    0.69969 
   3      x3 (+)        31912.722    31952.239    -24845.827    0.71466    0.71462 
   4      x2 (+)        29304.296    29351.717    -27453.243    0.74958    0.74953 
   5      x6 (-)        29302.317    29341.835    -27455.223    0.74958    0.74954 
   6      x4 (+)        29300.814    29348.235    -27456.724    0.74962    0.74957 
  --------------------------------------------------------------------------------

  Final Model Output 
  ------------------

                            Model Summary                           
  -----------------------------------------------------------------
  R                       0.866       RMSE                   0.503 
  R-Squared               0.750       MSE                    0.253 
  Adj. R-Squared          0.750       Coef. Var           6430.859 
  Pred R-Squared          0.749       AIC                29300.814 
  MAE                     0.402       SBC                29348.235 
  -----------------------------------------------------------------
   RMSE: Root Mean Square Error 
   MSE: Mean Square Error 
   MAE: Mean Absolute Error 
   AIC: Akaike Information Criteria 
   SBC: Schwarz Bayesian Criteria

                                     ANOVA                                    
  ---------------------------------------------------------------------------
                   Sum of                                                    
                  Squares           DF    Mean Square        F          Sig. 
  ---------------------------------------------------------------------------
  Regression    15163.528            4       3790.882    14966.061    0.0000 
  Residual       5064.705        19995          0.253                        
  Total         20228.233        19999                                       
  ---------------------------------------------------------------------------

                                    Parameter Estimates                                   
  ---------------------------------------------------------------------------------------
        model      Beta    Std. Error    Std. Beta      t        Sig      lower    upper 
  ---------------------------------------------------------------------------------------
  (Intercept)    -0.005         0.004                 -1.496    0.135    -0.012    0.002 
           x1     0.255         0.003        0.362    84.140    0.000     0.249    0.261 
           x3     0.253         0.003        0.356    82.604    0.000     0.247    0.259 
           x2     0.249         0.003        0.346    80.544    0.000     0.243    0.255 
           x4    -0.007         0.004       -0.007    -1.872    0.061    -0.014    0.000 
  ---------------------------------------------------------------------------------------


Try the olsrr package in your browser

Any scripts or data that you put into this service are public.

olsrr documentation built on May 29, 2024, 12:35 p.m.