The HPREG Procedure

Example 61.2 Backward Selection in Single-Machine and Distributed Modes

(View the complete code for this example.)

This example shows how you can run PROC HPREG in single-machine and distributed modes. See the section Processing Modes in SAS/STAT 14.2 User's Guide: High-Performance Procedures for details about the execution modes of SAS High-Performance Statistics procedures. The focus of this example is to simply show how you can switch the modes of execution of PROC HPREG, rather than on any statistical features of the procedure. The following DATA step generates the data for this example. The response y depends on 20 of the 1,000 regressors.

 data ex2Data;
    array x{1000};

    do i=1 to 10000;
       y=1;
       sign=1;

       do j=1 to 1000;
          x{j} = ranuni(1);
          if j<=20  then do;
            y = y + sign*j*x{j};
            sign=-sign;
          end;
       end;
       y = y + 5*rannor(1);
       output;
   end;
 run;

The following statements use PROC HPREG to select a model by using BACKWARD selection:

 proc hpreg data=ex2Data;
     model y = x: ;
     selection method = backward;
     performance details;
 run;

Output 61.2.1 shows the "Performance Information" table. This shows that the HPREG procedure executes in single-machine mode using four threads because the client machine has four CPUs. You can force a certain number of threads on any machine involved in the computations with the NTHREADS option in the PERFORMANCE statement.

Output 61.2.1: Performance Information

The HPREG Procedure

Performance Information
Execution ModeSingle-Machine
Number of Threads4


Output 61.2.2 shows the parameter estimates for the selected model. You can see that the default BACKWARD selection with selection and stopping based on the SBC criterion retains all 20 of the true effects but also keeps two extraneous effects.

Output 61.2.2: Parameter Estimates for the Selected Model

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValuePr > |t|
Intercept11.5066150.4198113.590.0003
x111.0544020.1769305.96<.0001
x21-1.9960800.176967-11.28<.0001
x313.2933310.17703218.60<.0001
x41-3.7412730.176349-21.22<.0001
x514.9083100.17604727.88<.0001
x61-5.7723560.176642-32.68<.0001
x717.3988220.17579242.09<.0001
x81-7.9584710.176281-45.15<.0001
x918.8994070.17762450.10<.0001
x101-9.6876670.176431-54.91<.0001
x11111.0833730.17519563.26<.0001
x121-12.0465040.176324-68.32<.0001
x13113.0090520.17696773.51<.0001
x141-14.4563930.175968-82.15<.0001
x15114.9287310.17486885.37<.0001
x161-15.7629070.177651-88.73<.0001
x17116.8428890.17703795.14<.0001
x181-18.4688440.176502-104.64<.0001
x19118.8101930.176616106.50<.0001
x201-20.2122910.176325-114.63<.0001
x871-0.5423840.176293-3.080.0021
x3621-0.5609990.176594-3.180.0015


Output 61.2.3 shows timing information for the PROC HPREG 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 forming the crossproducts matrix for the model that contains all the regressors.

Output 61.2.3: Timing

Procedure Task Timing
TaskSecondsPercent
Reading and Levelizing Data0.164.72%
Loading Design Matrix0.030.94%
Computing Moments0.010.45%
Computing Cross Products Matrix2.3972.18%
Performing Model Selection0.7221.71%


You can switch to running PROC HPREG 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. See the section Processing Modes in SAS/STAT 14.2 User's Guide: High-Performance Procedures for details about setting these options or environment variables.

The following statements provide an example. 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 hpreg data=ex2Data;
     model y = x: ;
     selection method = backward;
     performance details nodes = 10
                 host="&GRIDHOST" install="&GRIDINSTALLLOC";
 run;

The execution mode in the "Performance Information" table shown in Output 61.2.4 indicates that the calculations were performed in a distributed environment that uses 10 nodes, each of which uses eight threads.

Output 61.2.4: 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 issued by all high-performance statistical procedures in the SAS Log:

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

Output 61.2.5 shows timing information for this distributed run of the HPREG procedure. In contrast to the single-machine mode (where forming the crossproducts matrix dominated the time spent), the majority of time in distributed mode is spent distributing the data and performing the model selection.

Output 61.2.5: Timing

Procedure Task Timing
TaskSecondsPercent
Distributing Data0.8335.52%
Reading and Levelizing Data0.062.75%
Loading Design Matrix0.020.92%
Computing Moments0.020.68%
Computing Cross Products Matrix0.3213.64%
Performing Model Selection0.3314.12%
Waiting on Client0.7632.36%