title 'Stepwise simulation example - NO real predictors';
* Generate two sets of data: 100 random predictors, 200 observations;
data sim;
array x{100} x1-x100;
do testset= 1 to 2;
do n=1 to 200;
*-- generate the predictors-- all independent, just noise;
do i=1 to 100;
x(i) = normal(6752343);
end;
*-- generate the criterion-- no relation to any of the Xs;
y = normal(7654321);
output;
end;
end;
proc reg;
by testset;
model y = x1-x100 / selection=forward slentry=.05;
run;
/* Now see how well each prediction equation does in the other
data set.
- Each model should do well on the model for which it was
selected, but poorly on the other set of data
*/
title2 'Testing cross-validation';
proc reg data=sim;
by testset;
M1: model y = x13 x75 x5 x25 x82 x10 x38 x87 x94 x93 x29 x97;
M2: model y = x78 x14 x30 x25 x9 x4;