The HPREG Procedure

Example 61.3 Forward-Swap Selection

(View the complete code for this example.)

This example highlights the use of the forward-swap selection method, which is a generalization of the maximum R-square improvement (MAXR) method that is available in the REG procedure in SAS/STAT software. This example also demonstrates the use of the INCLUDE and START options.

The following DATA step produces the simulated data in which the response y depends on six main effects and three 2-way interactions from a set of 20 regressors.

  data ex3Data;
     array x{20};
     do i=1 to 10000;
        do j=1 to 20;
           x{j} = ranuni(1);
        end;
        y = 3*x1 + 7*x2 -5*x3 + 5*x1*x3 +
            4*x2*x13 + x7 + x11 -x13  + x1*x4 + rannor(1);
        output;
     end;
  run;

Suppose you want to find the best model of each size in a range of sizes for predicting the response y. You can use the forward-swap selection method to produce good models of each size without the computational expense of examining all possible models of each size. In this example, the criterion used to evaluate the models of each size is the model R square. With this criterion, the forward-swap method coincides with the MAXR method that is available in the REG procedure in SAS/STAT software. The model of a given size for which no pairwise swap of an effect in the model with any candidate effect improves the R-square value is deemed to be the best model of that size.

Suppose that you have prior knowledge that the regressors x1, x2, and x3 are needed in modeling the response y. Suppose that you also believe that some of the two-way interactions of these variables are likely to be important in predicting y and that some other two-way interactions might also be needed. You can use this prior information by specifying the selection process shown in the following statements:

 proc hpreg data=ex3Data;
     model y = x1|x2|x3|x4|x5|x6|x7|x8|x9|x10|X11|
               x12|x13|x14|x5|x16|x7|x18|x19|x20@2 /
                   include=(x1 x2 x3) start=(x1*x2 x1*x3 x2*x3);
     selection method=forwardswap(select=rsquare maxef=15 choose=sbc)
               details=all;
 run;

The MODEL statement specifies that all main effects and two-way interactions are candidates for selection. The INCLUDE= option specifies that the effects x1, x2, and x3 must appear in all models that are examined. The START= option specifies that all the two-way interactions of these variables should be used in the initial model that is considered but that these interactions are eligible for removal during the forward-swap selection.

The "Selection Summary" table is shown in Output 61.3.1.

Output 61.3.1: Selection Summary

The HPREG Procedure

Selection Summary
StepEffect
Entered
Effect
Removed
Number
Effects In
SBC Model
R-Square
0Intercept 1  
 x1 2  
 x2 3  
 x1*x2 4  
 x3 5  
 x1*x3 6  
 x2*x3 73307.68360.8837
1x2*x13 81892.84030.8992
2x7*x11x1*x28618.92980.9112
3x1*x4x2*x38405.37510.9131
4x13 9213.61400.9148
5x7 10180.44570.9152
6x11x7*x11101.4039*0.9167
7x10*x11 112.33930.9168
8x3*x7 124.50000.9168
9x6*x7 1310.05890.9169
10x3*x6 1413.11130.9169
11x5*x20 1519.46120.9169
12x13*x20x3*x61518.36780.9169
13x5*x5x6*x71512.13980.9170*

* Optimal Value of Criterion



You see that starting from the model with an intercept and the effects specified in the INCLUDE= and START= options at step 0, the forward-swap selection method adds the effect x2*x13 at step one, because this yields the maximum improvement in R square that can be obtained by adding a single effect. The forward-swap selection method now evaluates whether any effect swap yields a better eight-effect model (one with a higher R-square value). Because you specified the DETAILS=ALL option in the SELECTION statement, at each step where a swap is made you obtain a "Candidates" table that shows the R-square values for the evaluated swaps. Output 61.3.2 shows the "Candidates" for step 2. By default, only the best 10 swaps are displayed.

Output 61.3.2: Swap Candidates at Step 2

Best 10 Candidates
RankEffect
Dropped
Effect
Added
R-Square
1x1*x2x7*x110.9112
2x2*x3x7*x110.9112
3x1*x2x70.9065
4x2*x3x70.9065
5x1*x2x7*x70.9060
6x2*x3x7*x70.9060
7x1*x2x4*x70.9060
8x2*x3x4*x70.9060
9x1*x2x110.9058
10x2*x3x110.9058


You see that the best swap adds x7*x11 and drops x1*x2. This yields an eight-effect model whose R-square value (0.9112) is larger than the R-square value (0.8992) of the eight-effect model at step 1. Hence this swap is made at step 2. At step 3, an even better eight-effect model than the model at step 2 is obtained by dropping x2*x3 and adding x1*x4. No additional swap improves the R-square value, and so the model at step 3 is deemed to be the best eight-effect model. Although this is the best eight-effect model that can be found by this method given the starting model, it is not guaranteed that this model that has the highest R-square value among all possible models that consist of seven effects and an intercept.

Because the DETAILS=ALL option is specified in the SELECTION statement, details for the model at each step of the selection process are displayed. Output 61.3.3 provides details of the model at step 3.

Output 61.3.3: Model Details at Step 3

Analysis of Variance
SourceDFSum of
Squares
Mean
Square
F ValuePr > F
Model71086301551915000.3<.0001
Error9992103371.03455  
Corrected Total9999118967   

Root MSE1.01713
R-Square0.91311
Adj R-Sq0.91305
AIC10350
AICC10350
SBC405.37511
ASE1.03373

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValuePr > |t|
Intercept10.0120950.0457120.260.7913
x113.0870780.07639040.41<.0001
x217.7751800.046815166.08<.0001
x31-4.9571400.070995-69.82<.0001
x1*x314.9101150.12250340.08<.0001
x1*x410.8904360.06052314.71<.0001
x7*x1111.7084690.04593937.19<.0001
x2*x1312.5840780.06150642.01<.0001


The forward-swap method continues to find the best nine-effect model, best 10-effect model, and so on until it obtains the best 15-effect model. At this point the selection terminates because you specified the MAXEF=15 option in the SELECTION statement. The R-square value increases at each step of the selection process. However, because you specified the CHOOSE=SBC criterion in the SELECTION statement, the final model selected is the model at step 6.