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
| Selection Information | |
|---|---|
| Selection Method | LASSO |
| Choose Criterion | Validation ASE |
| Stop Criterion | SBC |
| Effect Hierarchy Enforced | None |
| Stop Horizon | 3 |
| Number of Observations Read | 322 |
|---|---|
| Number of Observations Used | 263 |
| Number of Observations Used for Training | 124 |
| Number of Observations Used for Validation | 139 |
| Number of Observations Used for Testing | 0 |
| Dimensions | |
|---|---|
| Number of Effects | 19 |
| Number of Parameters | 19 |
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
| Selection Summary | |||||
|---|---|---|---|---|---|
| Step | Effect Entered | Effect Removed | Number Effects In | SBC | Validation ASE |
| 0 | Intercept | 1 | -26.8275 | 0.7992 | |
| 1 | CrRbi | 2 | -47.5668 | 0.6415 | |
| 2 | nRBI | 3 | -50.9604 | 0.5958 | |
| 3 | nBB | 4 | -47.0607 | 0.5908 | |
| 4 | CrAtBat | 5 | -56.0563 | 0.5184 | |
| 5 | YrMajor | 6 | -71.9243 | 0.4330 | |
| 6 | nHits | 7 | -69.4898 | 0.4233 | |
| 7 | nAtBat | 8 | -78.6487 | 0.3766 | |
| 8 | CrHits | 9 | -75.8090 | 0.3708 | |
| 9 | nHome | 10 | -73.9605 | 0.3649 | |
| 10 | CrRbi | 9 | -80.4248 | 0.3618 | |
| 11 | CrAtBat | 8 | -87.0397* | 0.3591 | |
| 12 | nOuts | 9 | -86.1885 | 0.3534 | |
| 13 | Division_East | 10 | -83.3840 | 0.3489 | |
| 14 | nError | 11 | -81.3255 | 0.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
| Analysis of Variance | |||||
|---|---|---|---|---|---|
| Source | DF | Sum of Squares | Mean Square | F Value | Pr > F |
| Model | 10 | 54.10354 | 5.41035 | 14.57 | <.0001 |
| Error | 113 | 41.96456 | 0.37137 | ||
| Corrected Total | 123 | 96.06810 | |||
| Root MSE | 0.60940 |
|---|---|
| R-Square | 0.56318 |
| Adj R-Sq | 0.52452 |
| AIC | 13.65144 |
| AICC | 16.46225 |
| SBC | -81.32546 |
| ASE (Train) | 0.33842 |
| ASE (Validate) | 0.34880 |
| Parameter Estimates | ||
|---|---|---|
| Parameter | DF | Estimate |
| Intercept | 1 | 4.143832 |
| Division_East | 1 | 0.078574 |
| nAtBat | 1 | 0.001202 |
| nHits | 1 | 0.001017 |
| nHome | 1 | 0.014405 |
| nRBI | 1 | 0 |
| nBB | 1 | 0.007625 |
| YrMajor | 1 | 0.095327 |
| CrHits | 1 | 0.000009670 |
| nOuts | 1 | 0.000141 |
| nError | 1 | -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

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

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
| Analysis of Variance | |||||
|---|---|---|---|---|---|
| Source | DF | Sum of Squares | Mean Square | F Value | Pr > F |
| Model | 6 | 53.21414 | 8.86902 | 24.21 | <.0001 |
| Error | 117 | 42.85396 | 0.36627 | ||
| Corrected Total | 123 | 96.06810 | |||
| Root MSE | 0.60521 |
|---|---|
| R-Square | 0.55392 |
| Adj R-Sq | 0.53105 |
| AIC | 8.25204 |
| AICC | 9.50421 |
| SBC | -98.00599 |
| ASE (Train) | 0.34560 |
| ASE (Validate) | 0.34501 |
| Parameter Estimates | ||
|---|---|---|
| Parameter | DF | Estimate |
| Intercept | 1 | 4.203747 |
| Division_East | 1 | 0.031888 |
| nHits | 1 | 0.004381 |
| nHome | 1 | 0.017141 |
| nBB | 1 | 0.009164 |
| YrMajor | 1 | 0.093256 |
| CrHits | 1 | 0.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
| Number of Observations Read | 40 |
|---|---|
| Number of Observations Used | 30 |
| Number of Observations Used for Training | 15 |
| Number of Observations Used for Validation | 15 |
| Number of Observations Used for Testing | 0 |
| Dimensions | |
|---|---|
| Number of Effects | 19 |
| Number of Parameters | 19 |
Output 22.2.8: Details of the Model Selected by LASSO Selection for baseball_C Data
| Analysis of Variance | |||||
|---|---|---|---|---|---|
| Source | DF | Sum of Squares | Mean Square | F Value | Pr > F |
| Model | 5 | 8.70333 | 1.74067 | 3.95 | 0.0356 |
| Error | 9 | 3.96189 | 0.44021 | ||
| Corrected Total | 14 | 12.66521 | |||
| Root MSE | 0.66348 |
|---|---|
| R-Square | 0.68718 |
| Adj R-Sq | 0.51340 |
| AIC | 9.03005 |
| AICC | 25.03005 |
| SBC | -3.72165 |
| ASE (Train) | 0.26413 |
| ASE (Validate) | 0.30621 |
| Parameter Estimates | ||
|---|---|---|
| Parameter | DF | Estimate |
| Intercept | 1 | 5.093821 |
| nHits | 1 | 0.001115 |
| nRuns | 1 | 0.006507 |
| nBB | 1 | 0.004172 |
| CrAtBat | 1 | 0.000237 |
| nAssts | 1 | 0.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
| Root MSE | 0.60490 |
|---|---|
| R-Square | 0.82666 |
| Adj R-Sq | 0.59553 |
| AIC | 6.17483 |
| AICC | 61.17483 |
| SBC | -4.45272 |
| ASE (Train) | 0.14636 |
| ASE (Validate) | 0.17967 |
| Parameter Estimates | ||
|---|---|---|
| Parameter | DF | Estimate |
| Intercept | 1 | 4.435995 |
| nHits | 1 | 0.001148 |
| nRuns | 1 | 0.007537 |
| nBB | 1 | 0.006697 |
| YrMajor | 1 | 0.028748 |
| CrAtBat | 1 | 0.000118 |
| CrHits | 1 | 0.000383 |
| nAssts | 1 | 0.003097 |
| nError | 1 | 0.017681 |
Output 22.2.10: Elastic Net Selection Summary for baseball_C Data
| Elastic Net Summary | |||
|---|---|---|---|
| ENstep | L2 | Number Effects In | Validation ASE |
| 1 | 0.00000000 | 6 | 0.3062 |
| 2 | 0.00000001 | 6 | 0.3062 |
| 3 | 0.00000001 | 6 | 0.3062 |
| 4 | 0.00000002 | 6 | 0.3062 |
| 5 | 0.00000003 | 6 | 0.3062 |
| 6 | 0.00000005 | 6 | 0.3062 |
| 7 | 0.00000007 | 6 | 0.3062 |
| 8 | 0.00000010 | 6 | 0.3062 |
| 9 | 0.00000015 | 6 | 0.3062 |
| 10 | 0.00000022 | 6 | 0.3062 |
| 11 | 0.00000032 | 6 | 0.3062 |
| 12 | 0.00000046 | 6 | 0.3062 |
| 13 | 0.00000068 | 6 | 0.3062 |
| 14 | 0.00000100 | 6 | 0.3062 |
| 15 | 0.00000147 | 6 | 0.3062 |
| 16 | 0.00000215 | 6 | 0.3062 |
| 17 | 0.00000316 | 6 | 0.3062 |
| 18 | 0.00000464 | 6 | 0.3062 |
| 19 | 0.00000681 | 6 | 0.3062 |
| 20 | 0.00001000 | 6 | 0.3062 |
| 21 | 0.00001468 | 6 | 0.3062 |
| 22 | 0.00002154 | 6 | 0.3062 |
| 23 | 0.00003162 | 6 | 0.3062 |
| 24 | 0.00004642 | 6 | 0.3062 |
| 25 | 0.00006813 | 6 | 0.3062 |
| 26 | 0.00010000 | 6 | 0.3062 |
| 27 | 0.00014678 | 6 | 0.3062 |
| 28 | 0.00021544 | 6 | 0.3063 |
| 29 | 0.00031623 | 6 | 0.2029 |
| 30 | 0.00046416 | 6 | 0.2030 |
| 31 | 0.00068129 | 6 | 0.2031 |
| 32 | 0.00100000 | 6 | 0.2033 |
| 33 | 0.00146780 | 6 | 0.2036 |
| 34 | 0.00215443 | 6 | 0.2040 |
| 35 | 0.00316228 | 6 | 0.2046 |
| 36 | 0.00464159 | 7 | 0.3064 |
| 37 | 0.00681292 | 7 | 0.3058 |
| 38 | 0.01000000 | 7 | 0.2094 |
| 39 | 0.01467799 | 7 | 0.2122 |
| 40 | 0.02154435 | 8 | 0.2147 |
| 41 | 0.03162278 | 9 | 0.1993 |
| 42 | 0.04641589 | 9 | 0.1803 |
| 43 | 0.06812921 | 9 | 0.1866 |
| 44 | 0.10000000 | 9 | 0.1854 |
| 45 | 0.14677993 | 9 | 0.1797* |
| 46 | 0.21544347 | 9 | 0.2985 |
| 47 | 0.31622777 | 4 | 0.5786 |
| 48 | 0.46415888 | 4 | 0.6210 |
| 49 | 0.68129207 | 4 | 0.6675 |
| 50 | 1.00000000 | 4 | 0.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
| Root MSE | 0.46566 |
|---|---|
| R-Square | 0.86303 |
| Adj R-Sq | 0.76031 |
| AIC | -1.35829 |
| AICC | 22.64171 |
| SBC | -13.40194 |
| ASE (Train) | 0.11565 |
| ASE (Validate) | 0.16609 |
| Parameter Estimates | ||
|---|---|---|
| Parameter | DF | Estimate |
| Intercept | 1 | 4.159782 |
| nRuns | 1 | 0.015687 |
| nBB | 1 | 0.003749 |
| YrMajor | 1 | 0.027027 |
| CrAtBat | 1 | 0.000256 |
| nAssts | 1 | 0.002826 |
| nError | 1 | 0.029585 |
Output 22.2.12: Adaptive Elastic Net Selection Summary for baseball_C Data
| Elastic Net Summary | |||
|---|---|---|---|
| ENstep | L2 | Number Effects In | Validation ASE |
| 1 | 0.00000000 | 6 | 0.2780 |
| 2 | 0.00000001 | 5 | 0.1736 |
| 3 | 0.00000001 | 5 | 0.1736 |
| . | . | . | |
| . | . | . | |
| . | . | . | |
| 37 | 0.00681292 | 6 | 0.1952 |
| 38 | 0.01000000 | 5 | 0.1789 |
| 39 | 0.01467799 | 6 | 0.1667 |
| 40 | 0.02154435 | 7 | 0.1661* |
| 41 | 0.03162278 | 7 | 0.1688 |
| 42 | 0.04641589 | 6 | 0.1986 |
| 43 | 0.06812921 | 6 | 0.2385 |
| . | . | . | |
| . | . | . | |
| . | . | . | |
| 48 | 0.46415888 | 4 | 0.5973 |
| 49 | 0.68129207 | 4 | 0.6637 |
| 50 | 1.00000000 | 4 | 0.7061 |
| * Optimal Value Of Criterion | |||