The REG Procedure

Interactive Analysis

PROC REG enables you to change interactively both the model and the data used to compute the model, and to produce and highlight scatter plots. See the section Using PROC REG Interactively for an overview of interactive analysis that uses PROC REG. The following statements can be used interactively (without reinvoking PROC REG): ADD, DELETE, MODEL, MTEST, OUTPUT, PAINT, PLOT, PRINT, REFIT, RESTRICT, REWEIGHT, and TEST. All interactive features are disabled if there is a BY statement.

The ADD, DELETE, and REWEIGHT statements can be used to modify the current MODEL. Every use of an ADD, DELETE, or REWEIGHT statement causes the model label to be modified by attaching an additional number to it. This number is the cumulative total of the number of ADD, DELETE, or REWEIGHT statements following the current MODEL statement.

A more detailed explanation of changing the data used to compute the model is given in the section Reweighting Observations in an Analysis.

The following statements illustrate the usefulness of the interactive features. First, the full regression model is fit to the Sashelp.Class data, and Figure 99.26 is produced.

ods graphics on;

proc reg data=sashelp.Class plots(modelLabel only)=ResidualByPredicted;
   model Weight=Age Height;
run;

Figure 99.26: Interactive Analysis: Full Model

The REG Procedure
Model: MODEL1
Dependent Variable: Weight

Analysis of Variance
SourceDFSum of
Squares
Mean
Square
F ValuePr > F
Model27215.637103607.8185527.23<.0001
Error162120.09974132.50623  
Corrected Total189335.73684   

Root MSE11.51114R-Square0.7729
Dependent Mean100.02632Adj R-Sq0.7445
Coeff Var11.50811  

Parameter Estimates
VariableDFParameter
Estimate
Standard
Error
t ValuePr > |t|
Intercept1-141.2237633.38309-4.230.0006
Age11.278393.110100.410.6865
Height13.597030.905463.970.0011


Next, the regression model is reduced by the following statements, and Figure 99.27 is produced.

   delete age;
   print;
run;

Figure 99.27: Interactive Analysis: Reduced Model

Analysis of Variance
SourceDFSum of
Squares
Mean
Square
F ValuePr > F
Model17193.249127193.2491257.08<.0001
Error172142.48772126.02869  
Corrected Total189335.73684   

Root MSE11.22625R-Square0.7705
Dependent Mean100.02632Adj R-Sq0.7570
Coeff Var11.22330  

Parameter Estimates
VariableDFParameter
Estimate
Standard
Error
t ValuePr > |t|
Intercept1-143.0269232.27459-4.430.0004
Height13.899030.516097.55<.0001


Note that the MODEL label has been changed from MODEL1 to MODEL1.1, since the original MODEL has been changed by the delete statement.

When ODS Graphics is enabled, updated plots are produced whenever a PRINT statement is used. The option

plots(modelLabel only)=ResidualByPredicted

in the PROC REG statement specifies that the only plot produced is a scatter plot of residuals by predicted values. The MODELLABEL option specifies that the current model label is added to the plot.

The following statements generate a scatter plot of the residuals against the predicted values from the full model. Figure 99.28 is produced, and the scatter plot shows a possible outlier.

   add age;
   print;
run;

Figure 99.28: Interactive Analysis: Scatter Plot

Interactive Analysis: Scatter Plot


The following statements delete the observation with the largest residual, refit the regression model, and produce a scatter plot of residuals against predicted values for the refitted model. Figure 99.29 shows the new scatter plot.

   reweight r.>20;
   print;
run;

Figure 99.29: Interactive Analysis: Scatter Plot

Interactive Analysis: Scatter Plot