The HPGENSELECT Procedure

Example 53.4 Model Selection by the LASSO Method

(View the complete code for this example.)

This example shows how you can use PROC HPGENSELECT to perform model selection among Poisson regression models by using the LASSO method in single-machine and distributed modes. For more information about the execution modes of SAS High-Performance Statistics procedures, see the section Processing Modes in SAS/STAT 14.2 User's Guide: High-Performance Procedures. The focus of this example is to show how you use the LASSO method and how you can switch the modes of execution of PROC HPGENSELECT. The following DATA step generates the data for this example. There are 1,000,000 observations in the data set, and the response yPoisson is a Poisson variable with a mean that depends on 20 of the 100 regressors.

%let nObs      = 1000000;
%let nContIn   = 20;
%let nContOut  = 80;
%let Seed      = 12345;

data ex4Data;
array xIn{&nContIn};
array xOut{&nContOut};

drop i j sign xBeta expXbeta;

seed = &Seed;
do i=1 to &nObs;
   sign  = -1;
       xBeta = 0;
       do j=1 to dim(xIn);
           call ranuni(seed,xIn[j]);
           xBeta  = xBeta + j*sign*xIn{j};
           sign   = -sign;
       end;

       do j=1 to dim(xOut);
          call ranuni(seed,xOut[j]);
       end;

       call ranuni(seed,xSubtle);
       call ranuni(seed,xTiny);

       xBeta = xBeta + 0.1*xSubtle + 0.05*xTiny;
       expXbeta = exp(xBeta/20);
       call ranpoi(seed,expXbeta,yPoisson);
       output;
end;
run;

The following statements use PROC HPGENSELECT to select a model by using the LASSO method and only the first 10,000 observations:

proc hpgenselect data=ex4Data(Obs=10000);
   model yPoisson = x: / dist=Poisson;
   selection method=Lasso(choose=SBC) details=all;
   performance details;
run;

Output 53.4.1 shows the "Performance Information" table. This shows that the HPGENSELECT procedure executed in single-machine mode on four threads because the client machine has four CPUs. You can select a certain number of threads on any machine involved in the computations by using the NTHREADS= option in the PERFORMANCE statement.

Output 53.4.1: Performance Information

The HPGENSELECT Procedure

Performance Information
Execution ModeSingle-Machine
Number of Threads4


Output 53.4.2 shows the models fit by maximizing the penalized log likelihoods for a sequence of regularization parameters. For each step in the sequence, Output 53.4.2 shows you the effects that are added or removed and the fit statistics AIC, AICC, and BIC (SBC) for each model. Unlike other methods, such as forward selection, LASSO selection includes zero or more effects in each step.

Output 53.4.2: Selection Details

Selection Details
StepDescriptionEffects
In Model
LambdaAICAICCBIC
0Initial Model1139592.39939592.39939599.609
1xIn17 entered50.838533.06038533.06638569.111
 xIn18 entered50.838533.06038533.06638569.111
 xIn19 entered50.838533.06038533.06638569.111
 xIn20 entered50.838533.06038533.06638569.111
2xIn14 entered80.6436731.49836731.51336789.181
 xIn15 entered80.6436731.49836731.51336789.181
 xIn16 entered80.6436731.49836731.51336789.181
3xIn11 entered110.51234887.97934888.00534967.292
 xIn12 entered110.51234887.97934888.00534967.292
 xIn13 entered110.51234887.97934888.00534967.292
4xIn8 entered120.409633321.73733321.76933408.262
5xIn7 entered150.327732043.42832043.47632151.583
 xIn9 entered150.327732043.42832043.47632151.583
 xIn10 entered150.327732043.42832043.47632151.583
6xIn6 entered160.262131135.41131135.46531250.776
7xIn5 entered170.209730494.51230494.57330617.088
8xIn4 entered180.167830062.39730062.46530192.183
9xIn3 entered190.134229761.38429761.46029898.380
10xIn2 entered200.107429563.60329563.68729707.810
11 200.085929432.71629432.80029576.922
12 200.068729348.85629348.94029493.063
13xOut8 entered220.05529297.96129298.06229456.588
 xOut66 entered220.05529297.96129298.06229456.588
14xIn1 entered260.04429265.88229266.02229453.350*
 xOut34 entered260.04429265.88229266.02229453.350*
 xOut37 entered260.04429265.88229266.02229453.350*
 xOut65 entered260.04429265.88229266.02229453.350*
15xOut7 entered320.035229247.13629247.34829477.867
 xOut22 entered320.035229247.13629247.34829477.867
 xOut29 entered320.035229247.13629247.34829477.867
 xOut51 entered320.035229247.13629247.34829477.867
 xOut57 entered320.035229247.13629247.34829477.867
 xOut60 entered320.035229247.13629247.34829477.867
16xOut1 entered440.028129244.46129244.85929561.716
 xOut6 entered440.028129244.46129244.85929561.716
 xOut14 entered440.028129244.46129244.85929561.716
 xOut18 entered440.028129244.46129244.85929561.716
 xOut27 entered440.028129244.46129244.85929561.716
 xOut30 entered440.028129244.46129244.85929561.716
 xOut33 entered440.028129244.46129244.85929561.716
 xOut53 entered440.028129244.46129244.85929561.716
 xOut56 entered440.028129244.46129244.85929561.716
 xOut59 entered440.028129244.46129244.85929561.716
 xOut62 entered440.028129244.46129244.85929561.716
 xTiny entered440.028129244.46129244.85929561.716
17xOut11 entered560.022529245.66529246.30729649.444
 xOut24 entered560.022529245.66529246.30729649.444
 xOut35 entered560.022529245.66529246.30729649.444
 xOut36 entered560.022529245.66529246.30729649.444
 xOut43 entered560.022529245.66529246.30729649.444
 xOut45 entered560.022529245.66529246.30729649.444
 xOut49 entered560.022529245.66529246.30729649.444
 xOut54 entered560.022529245.66529246.30729649.444
 xOut69 entered560.022529245.66529246.30729649.444
 xOut75 entered560.022529245.66529246.30729649.444
 xOut76 entered560.022529245.66529246.30729649.444
 xOut79 entered560.022529245.66529246.30729649.444
18xOut12 entered630.01829241.97429242.78629696.225
 xOut19 entered630.01829241.97429242.78629696.225
 xOut28 entered630.01829241.97429242.78629696.225
 xOut48 entered630.01829241.97429242.78629696.225
 xOut61 entered630.01829241.97429242.78629696.225
 xOut78 entered630.01829241.97429242.78629696.225
 xSubtle entered630.01829241.97429242.78629696.225
19xOut4 entered690.014429241.23129242.20329738.744
 xOut39 entered690.014429241.23129242.20329738.744
 xOut40 entered690.014429241.23129242.20329738.744
 xOut44 entered690.014429241.23129242.20329738.744
 xOut67 entered690.014429241.23129242.20329738.744
 xOut71 entered690.014429241.23129242.20329738.744
20xOut2 entered790.011529251.88429253.15829821.500
 xOut3 entered790.011529251.88429253.15829821.500
 xOut16 entered790.011529251.88429253.15829821.500
 xOut21 entered790.011529251.88429253.15829821.500
 xOut31 entered790.011529251.88429253.15829821.500
 xOut41 entered790.011529251.88429253.15829821.500
 xOut46 entered790.011529251.88429253.15829821.500
 xOut50 entered790.011529251.88429253.15829821.500
 xOut72 entered790.011529251.88429253.15829821.500
 xOut77 entered790.011529251.88429253.15829821.500

* Optimal Value of Criterion



The model in step 14 had the smallest Schwarz Bayesian criterion (BIC in Output 53.4.2), and it was chosen as the final model because the CHOOSE=SBC option was specified in the SELECTION statement. Output 53.4.3 shows the parameter estimates for the selected model. You can see that the LASSO selection in which the final model was chosen based on the SBC criterion retains all 20 of the true effects but also keeps several extraneous effects.

Output 53.4.3: Parameter Estimates for the Selected Model

Parameter Estimates
ParameterDFEstimate
Intercept1-0.008605
xIn11-0.004242
xIn210.076690
xIn31-0.141401
xIn410.160843
xIn51-0.219377
xIn610.268402
xIn71-0.336859
xIn810.384260
xIn91-0.407838
xIn1010.397287
xIn111-0.516073
xIn1210.559396
xIn131-0.547200
xIn1410.631820
xIn151-0.692216
xIn1610.783101
xIn171-0.790773
xIn1810.875372
xIn191-0.837447
xIn2010.954752
xOut810.013643
xOut3410.002167
xOut3710.001344
xOut651-0.007790
xOut6610.015540


Output 53.4.4 shows timing information for the PROC HPGENSELECT run. This table is produced when you specify the DETAILS option in the PERFORMANCE statement. You can see that, in this case, the majority of time is spent in performing model selection.

Output 53.4.4: Timing

Procedure Task Timing
TaskSecondsPercent
Reading and Levelizing Data0.110.11%
Candidate model fit0.050.05%
Performing Model Selection104.0599.85%


You can switch to running PROC HPGENSELECT in distributed mode by specifying valid values for the NODES=, INSTALL=, and HOST= options in the PERFORMANCE statement. An alternative to specifying the INSTALL= and HOST= options in the PERFORMANCE statement is to set appropriate values for the GRIDHOST and GRIDINSTALLLOC environment variables by using OPTIONS SET commands. For more information about setting these options or environment variables, see the section Processing Modes in SAS/STAT 14.2 User's Guide: High-Performance Procedures.

The following statements provide an example. All 1,000,000 observations are used in this example of running PROC HPGENSELECT in distributed mode. To run these statements successfully, you need to set the macro variables GRIDHOST and GRIDINSTALLLOC to resolve to appropriate values, or you can replace the references to macro variables with appropriate values.

proc hpgenselect data=ex4Data;
   model yPoisson = x: / dist=Poisson;
   selection method=Lasso(choose=SBC) details=all;
   performance details nodes = 10
               host="&GRIDHOST" install="&GRIDINSTALLLOC";
run;

The Execution Mode row in the "Performance Information" table shown in Output 53.4.5 indicates that the calculations were performed in a distributed environment that used 10 nodes, each of which used 32 threads.

Output 53.4.5: Performance Information in Distributed Mode

Performance Information
Host Node<< your grid host >>
Install Location<< your grid install location >>
Execution ModeDistributed
Number of Compute Nodes10
Number of Threads per Node32


Another indication of distributed execution is the following message in the SAS log, which is issued by all high-performance statistical procedures:

NOTE: The HPGENSELECT procedure is executing in the distributed
      computing environment with 10 worker nodes.

Output 53.4.6 shows timing information for this distributed run of PROC HPGENSELECT. As in the case of the single-machine mode, the majority of time in distributed mode is spent in performing the model selection.

Output 53.4.6: Timing

Procedure Task Timing
TaskSecondsPercent
Distributing Data7.142.61%
Reading and Levelizing Data0.370.13%
Candidate model fit0.110.04%
Performing Model Selection265.9497.22%


Output 53.4.7 shows the models that were fit by maximizing the penalized log likelihoods for a sequence of regularization parameters. In this case, the model in the last step had the smallest SBC statistic and was the selected model.

Output 53.4.7: Selection Details

Selection Details
StepDescriptionEffects
In Model
LambdaAICAICCBIC
0Initial Model113931380.083931380.083931391.90
1xIn16 entered60.83811013.613811013.613811084.50
 xIn17 entered60.83811013.613811013.613811084.50
 xIn18 entered60.83811013.613811013.613811084.50
 xIn19 entered60.83811013.613811013.613811084.50
 xIn20 entered60.83811013.613811013.613811084.50
2xIn13 entered90.643611604.923611604.923611711.26
 xIn14 entered90.643611604.923611604.923611711.26
 xIn15 entered90.643611604.923611604.923611711.26
3xIn11 entered110.5123424886.613424886.613425016.58
 xIn12 entered110.5123424886.613424886.613425016.58
4xIn9 entered130.40963273653.053273653.053273806.65
 xIn10 entered130.40963273653.053273653.053273806.65
5xIn7 entered150.32773160535.723160535.723160712.95
 xIn8 entered150.32773160535.723160535.723160712.95
6xIn6 entered160.26213080686.193080686.193080875.24
7xIn5 entered170.20973025122.513025122.513025323.38
8xIn4 entered180.16782987411.532987411.532987624.21
9xIn3 entered190.13422962303.012962303.012962527.50
10 190.10742945736.432945736.432945960.92
11xIn2 entered200.08592934645.352934645.362934881.66
12 200.06872927476.582927476.582927712.89
13 200.0552922886.502922886.502923122.81
14xIn1 entered210.0442919875.952919875.952920124.08
15 210.03522917896.152917896.152918144.28
16 210.02812916627.572916627.572916875.69
17 210.02252915816.542915816.542916064.66
18 210.0182915297.372915297.372915545.49
19 210.01442914965.032914965.032915213.16
20 210.01152914752.312914752.312915000.44*

* Optimal Value of Criterion



Output 53.4.8 shows the parameter estimates for the selected model. Selecting the final model based on the SBC criterion retains all 20 of the true effects and none of the extraneous effects.

Output 53.4.8: Parameter Estimates

Parameter Estimates
ParameterDFEstimate
Intercept10.011850
xIn11-0.037295
xIn210.090866
xIn31-0.137335
xIn410.188475
xIn51-0.238960
xIn610.287461
xIn71-0.336226
xIn810.389728
xIn91-0.438611
xIn1010.486188
xIn111-0.539309
xIn1210.587680
xIn131-0.637463
xIn1410.684980
xIn151-0.735036
xIn1610.790630
xIn171-0.836793
xIn1810.885972
xIn191-0.934294
xIn2010.985428