The REGSELECT Procedure

Example 22.2 LASSO and Elastic Net Selection

This example continues the investigation of the baseball data set that were introduced in the section Getting Started: REGSELECT Procedure. That example uses the default stepwise selection method, which is based on the SBC criterion to select a model. This example explores model selection by using LASSO and elastic net selection methods with validation.

You can use the following DATA step to load the Sashelp.Baseball data set into your CAS session:

     data mycas.baseball;
        set sashelp.baseball;
     run;

These statements assume that your CAS engine libref is named mycas, as in the section Using CAS Sessions and CAS Engine Librefs, but you can substitute any appropriately defined CAS engine libref.

The following statements perform LASSO selection with validation for the baseball data:

  ods graphics on;
  proc regselect data=mycas.baseball;
    partition roleVar = league(train='National' validate = 'American');
    class division;
    model logSalary = division nAtBat nHits nHome nRuns nRBI nBB
                      yrMajor crAtBat crHits crHome crRuns crRbi
                      crBB nOuts nAssts nError;
    selection  method = lasso(choose=validate) plots=all;
  run;

The PARTITION statement assigns observations to training and validation roles on the basis of the values of the input variable league. The CHOOSE=VALIDATE option in the SELECTION statement selects the model that yields the smallest average square error (ASE) value for the validation data.

Output 22.2.1 shows that 124 observations are used for model training, 139 observations are used for model validation, and the number of effects is 19.

Output 22.2.1: Basic Information about LASSO Selection for baseball Data

The REGSELECT Procedure

Selection Information
Selection MethodLASSO
Choose CriterionValidation ASE
Stop CriterionSBC
Effect Hierarchy EnforcedNone
Stop Horizon3

Number of Observations Read322
Number of Observations Used263
Number of Observations Used for Training124
Number of Observations Used for Validation139
Number of Observations Used for Testing0

Dimensions
Number of Effects19
Number of Parameters19


The "Selection Summary" table in Output 22.2.2 shows the effect that was added or dropped at each step of the selection process together with the SBC and validation ASE for the model at each step. You see that the local minimum of SBC occurs at step 11 and that three more steps are completed before the procedure stops (because STOPHORIZON=3). The model that has lowest SBC is not used as the selected model because CHOOSE=VALIDATE. Instead, the model at step 14 (where the validation ASE achieves a local minimum value) is selected. Details of this selected model are shown in Output 22.2.3.

Output 22.2.2: Selection Summary of LASSO Selection for baseball Data

The REGSELECT Procedure
 
Selection Details

Selection Summary
StepEffect
Entered
Effect
Removed
Number
Effects In
SBC Validation
ASE
0Intercept 1-26.82750.7992
1CrRbi 2-47.56680.6415
2nRBI 3-50.96040.5958
3nBB 4-47.06070.5908
4CrAtBat 5-56.05630.5184
5YrMajor 6-71.92430.4330
6nHits 7-69.48980.4233
7nAtBat 8-78.64870.3766
8CrHits 9-75.80900.3708
9nHome 10-73.96050.3649
10 CrRbi9-80.42480.3618
11 CrAtBat8-87.0397*0.3591
12nOuts 9-86.18850.3534
13Division_East 10-83.38400.3489
14nError 11-81.32550.3488*
* Optimal Value Of Criterion

Selection stopped at a local minimum of the SBC criterion.

The model at step 14 is selected where Validation ASE is 0.348804.

Selected Effects:Intercept Division_East nAtBat nHits nHome nRBI nBB YrMajor CrHits nOuts nError


Output 22.2.3: Details of the Model Selected by LASSO Selection for baseball Data

The REGSELECT Procedure
 
Selected Model

Analysis of Variance
SourceDFSum of
Squares
Mean
Square
F ValuePr > F
Model1054.103545.4103514.57<.0001
Error11341.964560.37137  
Corrected Total12396.06810   

Root MSE0.60940
R-Square0.56318
Adj R-Sq0.52452
AIC13.65144
AICC16.46225
SBC-81.32546
ASE (Train)0.33842
ASE (Validate)0.34880

Parameter Estimates
ParameterDFEstimate
Intercept14.143832
Division_East10.078574
nAtBat10.001202
nHits10.001017
nHome10.014405
nRBI10
nBB10.007625
YrMajor10.095327
CrHits10.000009670
nOuts10.000141
nError1-0.004048


The coefficient panel in Output 22.2.4 enables you to visualize the selection process. In this plot, standardized coefficients of all the effects that are selected at some step of the LASSO method are plotted as a function of the step number. The panel’s lower plot shows how the criterion that is used to choose the selected model changes as effects enter or leave the model.

Output 22.2.4: Lasso Coefficient Progression

Lasso Coefficient Progression


The criterion panel in Output 22.2.5 shows how the various fit criteria change as the LASSO selection method proceeds. This plot shows that if you had used the SBC statistic as the CHOOSE= criterion, then the selected model would be the model at step 11. However, the AIC and validation ASE continue to decline for all steps of the selection process.

The "Parameter Estimates" table in Output 22.2.3 shows that the coefficients of the parameters are in different scales. In this case, you can use the adaptive LASSO, in which adaptive weights are used for penalizing different coefficients in the L1 penalty. For more information about this selection method, see the section Adaptive LASSO Selection in Chapter 2, Shared Concepts.

Output 22.2.5: Criterion Panel

Criterion Panel


The following statements perform adaptive LASSO selection with validation for the baseball data:

 proc regselect data=mycas.baseball;
   partition roleVar = league(train='National' validate = 'American');
   class division;
   model logSalary = division nAtBat nHits nHome nRuns nRBI nBB
                     yrMajor crAtBat crHits crHome crRuns crRbi
                     crBB nOuts nAssts nError;
   selection  method = lasso(adaptive choose=validate);
 run;

The results of adaptive LASSO selection are shown in Output 22.2.6. You can see that the selected model for adaptive LASSO selection has fewer parameters and a lower validation ASE than LASSO selection has.

Output 22.2.6: Details of the Model Selected by Adaptive LASSO Selection for baseball Data

The REGSELECT Procedure
 
Selected Model

Analysis of Variance
SourceDFSum of
Squares
Mean
Square
F ValuePr > F
Model653.214148.8690224.21<.0001
Error11742.853960.36627  
Corrected Total12396.06810   

Root MSE0.60521
R-Square0.55392
Adj R-Sq0.53105
AIC8.25204
AICC9.50421
SBC-98.00599
ASE (Train)0.34560
ASE (Validate)0.34501

Parameter Estimates
ParameterDFEstimate
Intercept14.203747
Division_East10.031888
nHits10.004381
nHome10.017141
nBB10.009164
YrMajor10.093256
CrHits10.000028569


If you are interested only in the catchers’ salaries, you can use the following statements to perform LASSO selection for the baseball_C data:

  proc regselect data = mycas.baseball(where=(Position='C'));
    partition roleVar = league(train='National' validate = 'American');
    class division;
    model logSalary = division nAtBat nHits nHome nRuns nRBI nBB
                      yrMajor crAtBat crHits crHome crRuns crRbi
                      crBB nOuts nAssts nError;
    selection  method = lasso(choose=validate);
  run;

Output 22.2.7 shows that 15 observations were used for training and the number of effects is 19. This implies that you cannot obtain a good result by using LASSO selection because the number of effects is greater than the number of observations. In this case, you can use elastic net selection instead of LASSO selection. For more information about this selection method, see the section Elastic Net Selection in Chapter 2, Shared Concepts.

Output 22.2.7: Basic Information about LASSO Selection for baseball_C Data

The REGSELECT Procedure

Number of Observations Read40
Number of Observations Used30
Number of Observations Used for Training15
Number of Observations Used for Validation15
Number of Observations Used for Testing0

Dimensions
Number of Effects19
Number of Parameters19


Output 22.2.8: Details of the Model Selected by LASSO Selection for baseball_C Data

The REGSELECT Procedure
 
Selected Model

Analysis of Variance
SourceDFSum of
Squares
Mean
Square
F ValuePr > F
Model58.703331.740673.950.0356
Error93.961890.44021  
Corrected Total1412.66521   

Root MSE0.66348
R-Square0.68718
Adj R-Sq0.51340
AIC9.03005
AICC25.03005
SBC-3.72165
ASE (Train)0.26413
ASE (Validate)0.30621

Parameter Estimates
ParameterDFEstimate
Intercept15.093821
nHits10.001115
nRuns10.006507
nBB10.004172
CrAtBat10.000237
nAssts10.000372


The following statements perform elastic net selection for the baseball_C data:

   proc regselect data=mycas.baseball(where=(Position='C'));
     partition roleVar = league(train='National' validate = 'American');
     class division;
     model logSalary = division nAtBat nHits nHome nRuns nRBI nBB
                       yrMajor crAtBat crHits crHome crRuns crRbi
                       crBB nOuts nAssts nError;
     selection  method = elasticnet(choose=validate);
     ods output ElasticNetSummary=ElasticNetSummary;
   run;

You can specify the L2= suboption of the METHOD option in the SELECTION statement if you have a good estimate of the ridge regression parameter. If not, you can leave the L2= suboption unspecified; in this case, PROC REGSELECT estimates this regression parameter according to the criterion that is specified in the CHOOSE= option, by trying a series of candidate values for the ridge regression parameter. The optimal regression parameter is set to the value that achieves the minimum validation ASE.

The "Elastic Net Selection Summary" table in Output 22.2.10 shows that the optimal L2 value is 0.14677993 and the minimal validation ASE is 0.17967. Output 22.2.9 shows the details of the model that is selected by elastic net method with optimal L2 value. If you compare the ASE values for the model in Output 22.2.9 and the model in Output 22.2.8, you see that the elastic net method selects a model that has a lower validation ASE than the LASSO method does in this case.

Output 22.2.9: Details of the Model Selected by Elastic Net Selection for baseball_C Data

The REGSELECT Procedure
 
Selected Model

Root MSE0.60490
R-Square0.82666
Adj R-Sq0.59553
AIC6.17483
AICC61.17483
SBC-4.45272
ASE (Train)0.14636
ASE (Validate)0.17967

Parameter Estimates
ParameterDFEstimate
Intercept14.435995
nHits10.001148
nRuns10.007537
nBB10.006697
YrMajor10.028748
CrAtBat10.000118
CrHits10.000383
nAssts10.003097
nError10.017681


Output 22.2.10: Elastic Net Selection Summary for baseball_C Data

The REGSELECT Procedure
 
Selection Details

Elastic Net Summary
ENstepL2 Number
Effects In
Validation
ASE
10.0000000060.3062
20.0000000160.3062
30.0000000160.3062
40.0000000260.3062
50.0000000360.3062
60.0000000560.3062
70.0000000760.3062
80.0000001060.3062
90.0000001560.3062
100.0000002260.3062
110.0000003260.3062
120.0000004660.3062
130.0000006860.3062
140.0000010060.3062
150.0000014760.3062
160.0000021560.3062
170.0000031660.3062
180.0000046460.3062
190.0000068160.3062
200.0000100060.3062
210.0000146860.3062
220.0000215460.3062
230.0000316260.3062
240.0000464260.3062
250.0000681360.3062
260.0001000060.3062
270.0001467860.3062
280.0002154460.3063
290.0003162360.2029
300.0004641660.2030
310.0006812960.2031
320.0010000060.2033
330.0014678060.2036
340.0021544360.2040
350.0031622860.2046
360.0046415970.3064
370.0068129270.3058
380.0100000070.2094
390.0146779970.2122
400.0215443580.2147
410.0316227890.1993
420.0464158990.1803
430.0681292190.1866
440.1000000090.1854
450.1467799390.1797*
460.2154434790.2985
470.3162277740.5786
480.4641588840.6210
490.6812920740.6675
501.0000000040.7458
* Optimal Value Of Criterion


Similar to the previous analysis, which used the adaptive LASSO selection, you can also perform adaptive elastic net selection on the data when parameter estimates has different scales. The following statements perform adaptive elastic net selection for the baseball_C data:

proc regselect data=mycas.baseball(where=(Position='C'));
     partition roleVar = league(train='National' validate = 'American');
     class division;
     model logSalary = division nAtBat nHits nHome nRuns nRBI nBB
                       yrMajor crAtBat crHits crHome crRuns crRbi
                       crBB nOuts nAssts nError;
     selection  method = elasticnet(adaptive choose=validate);
run;
ods graphics off;

The "Adaptive Elastic Net Selection Summary" table in Output 22.2.12 shows that the optimal L2 value is 0.0215 and the minimal validation ASE is 0.1661. Output 22.2.11 shows that adaptive elastic net selection can produce better results in the sense of a lower validation ASE and a sparser model. For more information about this method, see the section Adaptive Elastic Net Selection in Chapter 2, Shared Concepts.

Output 22.2.11: Details of the Model Selected by Adaptive Elastic Net Selection for baseball_C Data

The REGSELECT Procedure
 
Selected Model

Root MSE0.46566
R-Square0.86303
Adj R-Sq0.76031
AIC-1.35829
AICC22.64171
SBC-13.40194
ASE (Train)0.11565
ASE (Validate)0.16609

Parameter Estimates
ParameterDFEstimate
Intercept14.159782
nRuns10.015687
nBB10.003749
YrMajor10.027027
CrAtBat10.000256
nAssts10.002826
nError10.029585


Output 22.2.12: Adaptive Elastic Net Selection Summary for baseball_C Data

Elastic Net Summary
ENstepL2 Number
Effects In
Validation
ASE
10.0000000060.2780
20.0000000150.1736
30.0000000150.1736
 ...
 ...
 ...
370.0068129260.1952
380.0100000050.1789
390.0146779960.1667
400.0215443570.1661*
410.0316227870.1688
420.0464158960.1986
430.0681292160.2385
 ...
 ...
 ...
480.4641588840.5973
490.6812920740.6637
501.0000000040.7061
* Optimal Value Of Criterion


Last updated: September 13, 2022