The QTRSELECT Procedure
Using Validation and Test Data
When you have sufficient data, you can subdivide your data into three parts called the training, validation, and test data. The selection process fits models to the training data and uses the validation data to find the prediction errors for the models that are obtained in this way. This prediction error on the validation data can be used to decide when to terminate the selection process or to decide what effects to include as the selection process proceeds. Finally, after a selected model has been obtained, the test data can be used to assess how the selected model generalizes on data that played no role in selecting the model.
In some cases you might want to use only training and test data. For example, you might want to use an information criterion to decide what effects to include and when to terminate the selection process. In this case no validation data are required, but test data can still help you assess the predictive performance of the selected model. In other cases you might decide to use validation data during the selection process but forgo assessing the selected model on test data. Hastie, Tibshirani, and Friedman (2001) note that it is difficult to give a general rule for how many observations you should assign to each role. They state that a typical split might be 50% for training and 25% each for validation and testing.
You use a PARTITION statement to logically subdivide the DATA= data table into separate roles. You can name the fractions of the data that you want to reserve as test data and validation data. For example, the following statements randomly subdivide the mycas.inData data table, reserving 50% for training and 25% each for validation and testing:
proc qtrselect data=mycas.inData; partition fraction(test=0.25 validate=0.25); ... run;
In some cases you might need to exercise more control over the partitioning of the input data table. You can do this by naming both a variable in the input data table and a formatted value of that variable that correspond to each role. For example, the following statements assign roles to the observations in the mycas.inData data table based on the value of the variable group in that data table. Observations in which the value of group is "group 1" are assigned to testing, and those whose value is "group 2" are assigned to training. All other observations are ignored.
proc qtrselect data=mycas.inData; partition roleVar=group(test='group 1' train='group 2') ... run;
After you reserve observations for training, validation, and testing, a model fit of the training data is scored on the validation and test data, and the average check loss (ACL) is computed separately for each of these subsets. The ACL for each data role is the sum of check losses for observations in that role divided by the number of observations in that role.
The following statements illustrate the use of the ROLEVAR= option:
%let seed=321;
%let n=600;
%let p=10;
data mycas.roleExample;
array x{&p} x1-x&p;
length r $8;
drop i j k;
do i=1 to &n;
do j=1 to &p;
x{j} = ranuni(&seed);
end;
y = x1 + x2 + x3 + ranuni(&seed);
k = mod(i,3);
if k=0 then r = 'train';
else if k=1 then r = 'validate';
else if k=2 then r = 'test';
output;
end;
run;
proc qtrselect data=mycas.roleExample;
model y = x1-x&p;
selection method=forward(select=validate stop=sbc);
partition rolevar=r(train='train' validate='validate' test='test');
run;
The "Number of Observations" table shown in Figure 18.14 displays the number of observations used for training, validation, and testing.
Figure 18.14: Number of Observations
The "Selection Summary" table shown in Figure 18.15 displays the validation ACL values for each step of the selection process.
Figure 18.15: Selection Summary
| Selection Summary | ||||
|---|---|---|---|---|
| Step | Effect Entered | Number Effects In | SBC | Validation ACL |
| 0 | Intercept | 1 | -588.4130 | 0.2150 |
| 1 | x3 | 2 | -645.5774 | 0.1826 |
| 2 | x1 | 3 | -730.3921 | 0.1478 |
| 3 | x2 | 4 | -831.1414* | 0.1241 |
| 4 | x4 | 5 | -827.0261 | 0.1226* |
| 5 | x6 | 6 | -821.8472 | 0.1227 |
| 6 | x8 | 7 | -816.8005 | 0.1229 |
| * Optimal Value Of Criterion | ||||
The "Fit Statistics" table shown in Figure 18.16 displays the training ACL, the validation ACL, and the testing ACL for the final model.
Figure 18.16: Fit Statistics
Using the Validation ACL as the SELECT= Criterion
If you provided observations for validation and specified a model selection method that uses the SELECT= criterion, then you can specify SELECT=VALIDATE as a suboption of the METHOD= option in the SELECTION statement. After each step, the selection process computes the validation ACL values for all the current candidate models. The candidate model that has the smallest validation ACL value usually serves as the model for the next selection step.
Using the Validation ACL as the STOP= Criterion
If you provided observations for validation, then you can specify STOP=VALIDATE as a suboption of the METHOD= option in the SELECTION statement. At step k of the selection process, the best candidate effect to enter or leave the current model is determined. Here, "best candidate" means the effect that gives the best value of the SELECT= criterion; this criterion does not need to be based on the validation data. The validation ACL for the model with this candidate effect added or removed is computed. If this validation ACL is greater than the validation ACL for the model at step k, then the selection process terminates at step k.
Using the Validation ACL as the CHOOSE= Criterion
When you specify the CHOOSE=VALIDATE suboption of the METHOD= option in the SELECTION statement, the validation ACL is computed for the models at each step of the selection process. The smallest model at any step that yields the smallest validation ACL is selected.