The HPREG Procedure

Getting Started: HPREG Procedure

(View the complete code for this example.)

The following example is closely modeled on the example in the section "Getting Started: GLMSELECT Procedure" in the SAS/STAT User's Guide.

The Sashelp.Baseball data set contains salary and performance information for Major League Baseball players who played at least one game in both the 1986 and 1987 seasons, excluding pitchers. The salaries (Sports Illustrated, April 20, 1987) are for the 1987 season and the performance measures are from 1986 (Collier Books, The 1987 Baseball Encyclopedia Update). The following step displays in Figure 61.1 the variables in the data set:

proc contents varnum data=sashelp.baseball;
   ods select position;
run;

Figure 61.1: Sashelp.Baseball Data Set

The CONTENTS Procedure

Variables in Creation Order
#VariableTypeLenLabel
1NameChar18Player's Name
2TeamChar14Team at the End of 1986
3nAtBatNum8Times at Bat in 1986
4nHitsNum8Hits in 1986
5nHomeNum8Home Runs in 1986
6nRunsNum8Runs in 1986
7nRBINum8RBIs in 1986
8nBBNum8Walks in 1986
9YrMajorNum8Years in the Major Leagues
10CrAtBatNum8Career Times at Bat
11CrHitsNum8Career Hits
12CrHomeNum8Career Home Runs
13CrRunsNum8Career Runs
14CrRbiNum8Career RBIs
15CrBBNum8Career Walks
16LeagueChar8League at the End of 1986
17DivisionChar8Division at the End of 1986
18PositionChar8Position(s) in 1986
19nOutsNum8Put Outs in 1986
20nAsstsNum8Assists in 1986
21nErrorNum8Errors in 1986
22SalaryNum81987 Salary in $ Thousands
23DivChar16League and Division
24logSalaryNum8Log Salary


Suppose you want to investigate whether you can model the players’ salaries for the 1987 season based on performance measures for the previous season. The aim is to obtain a parsimonious model that does not overfit this particular data, making it useful for prediction. This example shows how you can use PROC HPREG as a starting point for such an analysis. Since the variation of salaries is much greater for the higher salaries, it is appropriate to apply a log transformation to the salaries before doing the model selection.

The following statements select a model with the default settings for stepwise selection:

proc hpreg data=sashelp.baseball;
  class league division;
  model logSalary = nAtBat nHits nHome nRuns nRBI nBB
                    yrMajor crAtBat crHits crHome crRuns crRbi
                    crBB league division nOuts nAssts nError;
  selection method=stepwise;
run;

The default output from this analysis is presented in Figure 61.2 through Figure 61.6.

Figure 61.2: Performance, Data Access, Model, and Selection Information

The HPREG Procedure

Performance Information
Execution ModeSingle-Machine
Number of Threads4

Data Access Information
DataEngineRolePath
SASHELP.BASEBALLV9InputOn Client

Model Information
Data SourceSASHELP.BASEBALL
Dependent VariablelogSalary
Class ParameterizationGLM

Selection Information
Selection MethodStepwise
Select CriterionSBC
Stop CriterionSBC
Effect Hierarchy EnforcedNone
Stop Horizon3


Figure 61.2 displays the "Performance Information," "Data Access Information," "Model Information," and "Selection Information" tables. The "Performance Information" table shows that procedure executes in single-machine mode—that is, the model is fit on the machine where the SAS session executes. This run of the HPREG procedure was performed on a multicore machine with four CPUs; one computational thread was spawned per CPU.

The "Data Access Information" table shows that the input data set is accessed with the V9 (base) engine on the client machine.

The "Model Information" table identifies the data source and response and shows that the CLASS variables are parameterized in the GLM parameterization, which is the default.

The "Selection Information" provides details about the method and criteria used to perform the model selection. The requested selection method is a variant of the traditional stepwise selection where the decisions about what effects to add or drop at any step and when to terminate the selection are both based on the Schwarz Bayesian information criterion (SBC). The effect in the current model whose removal yields the maximal decrease in the SBC statistic is dropped provided this lowers the SBC value. When no further decrease in the SBC value can be obtained by dropping an effect in the model, the effect whose addition to the model yields the lowest SBC statistic is added and the whole process is repeated. The method terminates when dropping or adding any effect increases the SBC statistic.

Figure 61.3 displays the "Number of Observations," "Class Levels," and "Dimensions" tables. The "Number of Observations" table shows that of the 322 observations in the input data, only 263 observations are used in the analysis because there are observations with incomplete data. The "Class Level Information" table lists the levels of the classification variables "division" and "league." When you specify effects that contain classification variables, the number of parameters is usually larger than the number of effects. The "Dimensions" table shows the number of effects and the number of parameters considered.

Figure 61.3: Number of Observations, Class Levels, and Dimensions

Number of Observations Read322
Number of Observations Used263

Class Level Information
ClassLevelsValues
League2American National
Division2East West

Dimensions
Number of Effects19
Number of Parameters21


The "Stepwise Selection Summary" table in Figure 61.4 shows the effect that was added or dropped at each step of the selection process together with fit statistics for the model at each step. In this case, both selection and stopping are based on the SBC statistic.

Figure 61.4: Selection Summary Table

The HPREG Procedure

Selection Summary
StepEffect
Entered
Effect
Removed
Number
Effects In
SBC
0Intercept 1-57.2041
1CrRuns 2-194.3166
2nHits 3-252.5794
3YrMajor 4-262.7322
4 CrRuns3-262.8353
5nBB 4-269.7804*

* Optimal Value of Criterion



Figure 61.5 displays the "Stop Reason," "Selection Reason," and "Selected Effects" tables. Note that these tables are displayed without any titles. The "Stop Reason" table indicates that selection stopped because adding or removing any effect would worsen the SBC value that is used as the selection criterion. In this case, because no CHOOSE= criterion is specified in the SELECTION statement, the final model is the selected model; this is indicated in the "Selection Reason" table. The "Selected Effects" table lists the effects in the selected model.

Figure 61.5: Stopping and Selection Reasons

Stepwise selection stopped because adding or removing an effect does not improve the SBC criterion.

The model at step 5 is selected.

Selected Effects:Intercept nHits nBB YrMajor


The "Analysis of Variance," "Fit Statistics," and "Parameter Estimates" tables shown in Figure 61.6 give details of the selected model.

Figure 61.6: Details of the Selected Model

Analysis of Variance
SourceDFSum of
Squares
Mean
Square
F ValuePr > F
Model3120.5255340.17518120.12<.0001
Error25986.628200.33447  
Corrected Total262207.15373   

Root MSE0.57834
R-Square0.58182
Adj R-Sq0.57697
AIC-19.06903
AICC-18.83557
SBC-269.78041
ASE0.32938

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValuePr > |t|
Intercept14.0139110.11129036.07<.0001
nHits10.0079290.0009947.98<.0001
nBB10.0072800.0020493.550.0005
YrMajor10.1006630.00755113.33<.0001


You might want to examine regression diagnostics for the selected model to investigate whether collinearity among the selected parameters or the presence of outlying or high leverage observations might be impacting the fit produced. The following statements include some options and statements to obtain these diagnostics:

proc hpreg data=sashelp.baseball;
  id name;
  class league division;
  model logSalary = nAtBat nHits nHome nRuns nRBI nBB
                    yrMajor crAtBat crHits crHome crRuns crRbi
                    crBB league division nOuts nAssts nError / vif clb;
  selection method=stepwise;
  output out=baseballOut p=predictedLogSalary r h cookd rstudent;
run;

The VIF and CLB options in the MODEL statement request variance inflation factors and 95% confidence limits for the parameter estimates. Figure 61.7 shows the "Parameter Estimates" with these requested statistics. The variance inflation factors (VIF) measure the inflation in the variances of the parameter estimates due to collinearities that exist among the regressor (independent) variables. Although there are no formal criteria for deciding whether a VIF is large enough to affect the predicted values, the VIF values for the selected effects in this example are small enough to indicate that there are no collinearity issues among the selected regressors.

Figure 61.7: Parameter Estimates with Additional Statistics

The HPREG Procedure
Selected Model

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValuePr > |t|Variance
Inflation
95% Confidence Limits
Intercept14.0139110.11129036.07<.000103.794764.23306
nHits10.0079290.0009947.98<.00011.496420.005970.00989
nBB10.0072800.0020493.550.00051.521090.003250.01131
YrMajor10.1006630.00755113.33<.00011.024880.085790.11553


By default, high-performance statistical procedures do not include all variables from the input data set in output data sets. The ID statement specifies that the variable name in the input data set be added as an identification variable in the baseballOut data set that is produced by the OUTPUT statement. In addition to this variable, the OUTPUT statement requests that predicted values, raw residuals, leverage values, Cook’s D statistics, and studentized residuals be added in the output data set. Note that default names are used for these statistics except for the predicted values for which a specified name, predictedLogSalary, is supplied. The following statements use PROC PRINT to display the first five observations of this output data set:

proc print data=baseballOut(obs=5);
run;

Figure 61.8: First 5 Observations of the baseballOut Data Set

ObsNamepredictedLogSalaryResidualHCOOKDRSTUDENT
1Allanson, Andy4.73980.0.016087..
2Ashby, Alan6.34935-0.186030.012645.000335535-0.32316
3Davis, Alan5.899930.273850.019909.0011617940.47759
4Dawson, Andre6.50852-0.293920.011060.000730178-0.51031
5Galarraga, Andres5.12344-0.607110.009684.002720358-1.05510