The GLMSELECT Procedure

Example 50.6 Elastic Net and External Cross Validation

(View the complete code for this example.)

This example shows how to use the elastic net method for model selection and compares it with the LASSO method. The example also uses k-fold external cross validation as a criterion in the CHOOSE= option to choose the best model based on the penalized regression fit.

This example uses a microarray data set called the leukemia (LEU) data set (Golub et al. 1999), which is used in the paper by Zou and Hastie (2005) to demonstrate the performance of the elastic net method in comparison with that of LASSO. The LEU data set consists of 7,129 genes and 72 samples, and 38 samples are used as training samples. Among the 38 training samples, 27 are type 1 leukemia (acute lymphoblastic leukemia) and 11 are type 2 leukemia (acute myeloid leukemia). The goal is to construct a diagnostic rule based on the expression level of those 7,219 genes to predict the type of leukemia. The remaining 34 samples are used as the validation data for picking the appropriate model or as the test data for testing the performance of the selected model. The training and validation data sets are available from Sashelp.Leutrain and Sashelp.Leutest.

To have a basis for comparison, use the following statements to apply the LASSO method for model selection:

ods graphics on;
proc glmselect data=sashelp.Leutrain valdata=sashelp.Leutest
               plots=coefficients;
   model y = x1-x7129/
         selection=LASSO(steps=120  choose=validate);
run;

The details about the number of observations for training and validation data are given in Output 50.6.1 and Output 50.6.2, respectively.

Output 50.6.1: Number of Training Observations Table

The GLMSELECT Procedure

Observation Profile for Analysis Data
Number of Observations Read38
Number of Observations Used38
Number of Observations Used for Training38


Output 50.6.2: Number of Validation Observations Table

Observation Profile for Validation Data
Number of Observations Read34
Number of Observations Used34


Output 50.6.3 shows the "LASSO Selection Summary" table. Although the STEPS= suboption of the SELECTION= option specifies that 120 steps of LASSO selection be performed, the LASSO method terminates at step 81 because the selected model is a perfect fit and the number of effects that can be selected by LASSO is bounded by the number of training samples. Note that a VALDATA= data set is named in the PROC GLMSELECT statement and that the minimum of the validation ASE occurs at step 68. Hence the model at this step is selected, resulting in 35 selected effects. Output 50.6.4 shows the standardized coefficients of all the effects selected at some step of the LASSO method, plotted as a function of the step number.

Output 50.6.3: LASSO Selection Summary Table

The GLMSELECT Procedure
 
LASSO Selection Summary
 

StepEffect
Entered
Effect
Removed
Number
Effects In
ASEValidation
ASE
0Intercept 10.82271.0287
1x4847 20.78840.9787
2x3320 30.76100.9507
3x2020 40.49350.7061
4x5039 50.28380.5527
5x1249 60.27900.5518
6x2242 70.22550.5513
   ...
   ...
   ...
62x2534 350.00160.1554
63 x3320340.00160.1557
64x5631 350.00130.1532
65 x6021340.00120.1534
66 x1745330.00120.1535
67x6376 340.00120.1535
68x4831 350.00100.1531*
69 x6184340.00090.1539
70x3820 350.00060.1588
71x3171 360.00050.1615
72 x6376350.00040.1640
73x5142 360.00040.1659
74x1745 370.00030.1688
75x3605 380.00010.1821
76 x573370.00010.1825
77x3221 380.00010.1842
78 x1745370.00010.1842
79x6163 380.00000.1918
80 x4831370.00000.1920
81x1745 380.00000.1940
* Optimal Value of Criterion


Output 50.6.4: LASSO Coefficient Progression Plot

LASSO Coefficient Progression Plot


As discussed earlier, the number of effects that can be selected by the LASSO method is upper-bounded by the number of training samples. However, this is not a restriction for the elastic net method, which incorporates an additional ridge regression penalty. You can use the following statements to apply the elastic net method for model selection:

proc glmselect data=sashelp.Leutrain valdata=sashelp.Leutest
               plots=coefficients;
   model y = x1-x7129/
         selection=elasticnet(steps=120 L2=0.001 choose=validate);
run;

The L2= suboption of the SELECTION= option in the MODEL statement specifies the value of the ridge regression parameter. Output 50.6.5 shows the "Elastic Net Selection Summary" table. As in the example for LASSO, the STEPS= suboption of the SELECTION= option specifies that 120 steps of elastic net selection be performed. However, in contrast to the early termination in the LASSO method at step 81, the elastic net method runs until the specified 120 steps are performed. With the same VALDATA= data set named in the PROC GLMSELECT statement as in the LASSO example, the minimum of the validation ASE occurs at step 105, and hence the model at this step is selected, resulting in 54 selected effects. Compared with the LASSO method, the elastic net method can select more variables, and the number of selected variables is not restricted by the number of samples (38 for this example). Output 50.6.6 shows the standardized coefficients of all the effects that are selected at some step of the elastic net method, plotted as a function of the step number.

Output 50.6.5: Elastic Net Selection Summary Table

The GLMSELECT Procedure
 
Elastic Net Selection Summary
 

StepEffect
Entered
Effect
Removed
Number
Effects In
ASEValidation
ASE
0Intercept 10.82271.0287
1x4847 20.78850.9790
2x3320 30.76110.9510
3x2020 40.49390.7065
4x5039 50.28450.5533
5x1249 60.27990.5525
6x2242 70.22590.5517
   ...
   ...
   ...
100x259 530.00000.1207
101x1781 540.00000.1207
102 x7065530.00000.1198
103x4079 540.00000.1193
104 x6163530.00000.1193
105x6539 540.00000.1192*
106x6071 550.00000.1192
107x1829 560.00000.1192
108 x5598550.00000.1192
109x6169 560.00000.1192
110x1529 570.00000.1194
111x1306 580.00000.1194
112x5954 590.00000.1202
113x4271 600.00000.1203
114x3312 610.00000.1207
115x461 620.00000.1213
116x4697 630.00000.1228
117 x259620.00000.1231
118x4186 630.00000.1252
119 x4271620.00000.1258
120x4939 630.00000.1261
* Optimal Value of Criterion


Output 50.6.6: Elastic Net Coefficient Progression Plot

Elastic Net Coefficient Progression Plot


When you have a good estimate of the ridge regression parameter, you can specify the L2= suboption of the SELECTION= option in the MODEL statement. However, when you do not have a good estimate of the ridge regression parameter, you can leave the L2= option unspecified. In this case, PROC GLMSELECT estimates this regression parameter based on the criterion specified in the CHOOSE= option.

If you have a validation data set, you can use the following statements to apply the elastic net method of model selection:

proc glmselect data=sashelp.Leutrain valdata=sashelp.Leutest
               plots=coefficients;
   model y = x1-x7129/
         selection=elasticnet(steps=120 choose=validate);
run;

PROC GLMSELECT tries a series of candidate values for the ridge regression parameter, which you can control by using the L2HIGH=, L2LOW=, and L2SEARCH= options. The ridge regression parameter is set to the value that achieves the minimum validation ASE (see Figure 50.12 for an illustration). Output 50.6.7 shows the "Elastic Net Selection Summary" table. Compared to Output 50.6.5, where a ridge regression parameter is specified by the L2= option, this table shows that a slightly lower validation ASE is achieved as the value of the ridge regression parameter is optimized on the validation data set.

Output 50.6.7: Elastic Net Selection Summary Table

The GLMSELECT Procedure
 
Elastic Net Selection Summary
 

StepEffect
Entered
Effect
Removed
Number
Effects In
ASEValidation
ASE
0Intercept 10.82271.0287
1x4847 20.78840.9787
2x3320 30.76100.9508
3x2020 40.49360.7061
4x5039 50.28390.5527
5x1249 60.27900.5519
6x2242 70.22560.5513
   ...
   ...
   ...
110x3605 490.00000.1252
111x1975 500.00000.1241
112x6757 510.00000.1224
113 x3221500.00000.1206
114x2183 510.00000.1205
115x259 520.00000.1202
116x157 530.00000.1201
117x1781 540.00000.1197
118 x7065530.00000.1194
119x4079 540.00000.1187
120x6539 550.00000.1186*
* Optimal Value of Criterion


Output 50.6.8 shows the standardized coefficients of all the effects that are selected at some step of the elastic net method, plotted as a function of the step number.

Output 50.6.8: Elastic Net Coefficient Progression Plot

Elastic Net Coefficient Progression Plot


When validation data are not available, you can use other criteria supported by the CHOOSE= option for estimating the value of the ridge regression parameter. Criteria such as AIC, AICC, and BIC are defined for the training samples only, and they tend to set the value of the ridge regression parameter to 0 when the number of training samples is less than the number of variables. In this case, the elastic net method reduces to the LASSO method. As an alternative to AIC, AICC, and BIC, you can use either k-fold cross validation or k-fold external cross validation in the CHOOSE= option, where the criterion is computed for held-out data.

If you want to use k-fold cross validation for selecting the model and selecting the appropriate value for the ridge regression parameter, you can use the following statements to apply the elastic net method of model selection:

proc glmselect data=sashelp.Leutrain testdata=sashelp.Leutest
               plots=coefficients;
   model y = x1-x7129/
         selection=elasticnet(steps=120 choose=cv)cvmethod=split(4);
run;

Output 50.6.9: Elastic Net Selection Summary Table

The GLMSELECT Procedure
 
Elastic Net Selection Summary
 

StepEffect
Entered
Effect
Removed
Number
Effects In
ASETest ASECV PRESS
0Intercept 10.82271.028731.4370
1x4847 20.78840.978710.6957
2x3320 30.76100.950710.2065
3x2020 40.49350.70617.5478
4x5039 50.28390.55275.7695
5x1249 60.27900.55185.0187
6x2242 70.22550.55135.4050
   ....
   ....
   ....
80 x4831370.00000.191821.4320
81x1745 380.00000.192421.4320
82x4831 390.00000.193221.4320
83x2661 400.00000.185921.4320
84 x3605390.00000.185321.4319
85x5766 400.00000.176221.4319
86x6376 410.00000.173321.4327
87 x464400.00000.16743.9525
88 x4079390.00000.16731.7754
89x1987 400.00000.16241.4249
90x3605 410.00000.16161.4249
91x573 420.00000.15151.4249
92 x3221410.00000.15111.4157*
93x6021 420.00000.15041.4157
94 x2793410.00000.150930.9714
95x4820 420.00000.150430.9754
96x3320 430.00000.147930.9755
97x4399 440.00000.146130.9755
* Optimal Value of Criterion


A TESTDATA= data set is named in the PROC GLMSELECT statement; this is the same as the validation data set used earlier. Because the L2= option is not specified, PROC GLMSELECT tries a series of candidate values for the ridge regression parameter according to the CHOOSE=CV option, and the ridge regression parameter is set to the value that achieves the minimal CVPRESS score. Output 50.6.9 shows the "Elastic Net Selection Summary" table, which corresponds to the ridge regression parameter selected by k-fold cross validation. The elastic net method achieves the smallest CVPRESS score at step 92. Hence the model at this step is selected, resulting in 41 selected effects.

Output 50.6.10 shows the standardized coefficients of all the effects selected at some step of the elastic net method, plotted as a function of the step number. Note that k-fold cross validation uses a least squares fit to compute the CVPRESS score. Thus the criterion does not directly depend on the penalized regression used in the elastic net method, and the CVPRESS curve in Output 50.6.10 has abrupt jumps.

Output 50.6.10: Elastic Net Coefficient Progression Plot

Elastic Net Coefficient Progression Plot


If you want to perform the selection of both the ridge regression parameter and the selected variables in the model based on a criterion that directly depends on the regression used in the elastic net method, you can use k-fold external cross validation by specifying the following statements:

proc glmselect data=sashelp.Leutrain testdata=sashelp.Leutest
               plots=coefficients;
   model y = x1-x7129/
         selection=elasticnet(steps=120 choose=cvex)cvmethod=split(4);
run;

Output 50.6.11: Elastic Net Coefficient Progression Plot

Elastic Net Coefficient Progression Plot


As earlier, a TESTDATA= data set is named in the PROC GLMSELECT statement to test the prediction accuracy of the model on the training samples. Because the L2= option is not specified, PROC GLMSELECT tries a series of candidate values for the ridge regression parameter. Output 50.6.11 shows the standardized coefficients of all the effects selected at some step of the elastic net method, plotted as a function of the step number, and also the curve of the CVEXPRESS statistic as a function of the step number. A comparison between the criterion curves in Output 50.6.10 and Output 50.6.11 shows that the CVEXPRESS statistic is smoother than the CVPRESS statistic. Note that the CVEXPRESS statistic is based on a penalized model, whereas the CVPRESS statistic is based on an ordinary least squares model. Output 50.6.12 shows the "Elastic Net Selection Summary" table, which corresponds to the ridge regression parameter selected by k-fold external cross validation. The elastic net method achieves the smallest CVEXPRESS score at step 120, and hence the model at this step is selected, resulting in 53 selected effects.

Output 50.6.12: Elastic Net Selection Summary Table

The GLMSELECT Procedure
 
Elastic Net Selection Summary
 

StepEffect
Entered
Effect
Removed
Number
Effects In
ASETest ASECVEX PRESS
0Intercept 10.82271.02870.8265
1x4847 20.78840.97870.7940
2x3320 30.76100.95070.7698
3x2020 40.49360.70610.5195
4x5039 50.28390.55270.3554
5x1249 60.27900.55190.3526
6x2242 70.22550.55130.3218
7x6539 80.21610.54980.3166
8x6055 90.21280.54880.3148
9x1779 100.19680.52050.3096
10x3847 110.10650.37650.2671
11x4951 120.08910.34980.2586
12x1834 130.08680.34580.2579
13x1745 140.08370.33970.2570
14x6021 150.08090.33550.2561
15x6362 160.06670.31440.2510
16x2238 170.06210.30750.2498
   ....
   ....
   ....
100x2121 450.00000.14020.2350
101x6021 460.00000.13860.2334
102 x3171450.00000.13770.2324
103x4461 460.00000.13500.2302
104x4697 470.00000.13380.2299
105 x3605460.00000.13310.2293
106x3221 470.00000.13300.2289
107x5002 480.00000.13200.2282
108 x3820470.00000.13190.2281
109 x4697460.00000.13150.2278
110x4052 470.00000.12760.2235
111x6184 480.00000.12660.2229
112x3605 490.00000.12520.2215
113x1975 500.00000.12400.2212
114x6757 510.00000.12220.2200
115 x3221500.00000.12060.2185
116x2183 510.00000.12050.2185
117x259 520.00000.12020.2182
118x157 530.00000.12010.2181
119x1781 540.00000.11970.2177
120 x7065530.00000.11940.2177*
* Optimal Value of Criterion