The REG Procedure |
Traditional Graphics |
This section provides examples of using options available with the traditional graphics that you request with the PLOT statement. An alternative is to use ODS Graphics to obtain plots relevant to the analysis. See Example 74.1, Example 74.2, and Example 74.5 for examples of obtaining graphical displays with ODS Graphics. Examples in this section use the Fitness data set that is described in Example 74.2.
The following statements introduce the basic PLOT statement graphics syntax. A simple linear regression of Oxygen on RunTime is performed, and a plot of OxygenRunTime is requested. The fitted model, the regression line, and the four default statistics are also displayed in Figure 74.43.
proc reg data=fitness; model Oxygen=RunTime; plot Oxygen*RunTime / cframe=ligr; run;
You can use shorthand commands to plot the dependent variable, the predicted value, and the 95% confidence or prediction intervals against a regressor. The following statements use the CONF and PRED options to create a plot with confidence and prediction intervals. Results are displayed in Figure 74.44. Note that the statistics displayed by default in the margin are suppressed while three other statistics are exhibited. Furthermore, global graphics LEGEND and SYMBOL statements and PLOT statement options are used to control the appearance of the plot. For more information about the global graphics statements, see SAS/GRAPH Software: Reference.
legend1 position=(bottom left inside) across=1 cborder=red offset=(0,0) shape=symbol(3,1) label=none value=(height=.8); title 'Confidence and Prediction Intervals'; symbol1 c=yellow v=- h=1; symbol2 c=red; symbol3 c=blue; symbol4 c=blue; proc reg data=fitness; model Oxygen=RunTime / noprint; plot Oxygen*RunTime / pred nostat mse aic bic caxis=red ctext=blue cframe=ligr legend=legend1 modellab=' '; run;
When you use the SELECTION= option in the MODEL statement, you can produce plots showing model fit summary statistics for the models examined. The following statements produce the plot shown in Figure 74.45 of the statistic for model selection plotted against the number of parameters in the model; the CHOCKING= and CMALLOWS= options draw useful reference lines.
goptions ctitle=black htitle=3.5pct ftitle=swiss ctext =magenta htext =3.0pct ftext =swiss cback =ligr border; symbol1 v=circle c=red h=1 w=2; title 'Cp Plot with Reference Lines'; symbol1 c=green; proc reg data=fitness; model Oxygen=Age Weight RunTime RunPulse RestPulse MaxPulse / selection=rsquare noprint; plot cp.*np. / chocking=red cmallows=blue vaxis=0 to 15 by 5; run;
In the GOPTIONS statement,
frames the entire display.
specifies the background color.
selects the default color for the border and all text, including titles, footnotes, and notes.
specifies the title, footnote, note, and border color.
specifies the height for all text in the display.
specifies the height for the first title line.
selects the default font for all text, including titles, footnotes, notes, the model label and equation, the statistics, the axis labels, the tick values, and the legend.
specifies the first title font.
For more information about the GOPTIONS statement and other global graphics statements, see SAS/GRAPH Software: Reference.
The following statements create probability-probability plots and quantile-quantile plots of the residuals (Figure 74.46 and Figure 74.47, respectively). An annotation data set is created to produce the (0,0)(1,1) reference line for the P-P plot. Note that the NOSTAT option for the P-P plot suppresses the statistics that would be displayed in the margin.
data annote1; length function color $8; retain ysys xsys '2' color 'black'; function='move'; x=0; y=0; output; function='draw'; x=1; y=1; output; run; symbol1 c=blue; proc reg data=fitness; title 'PP Plot'; model Oxygen=RunTime / noprint; plot npp.*r. / annotate=annote1 nostat cframe=ligr modellab="'Best' Two-Parameter Model:"; run; title 'QQ Plot'; plot r.*nqq. / noline mse cframe=ligr modellab="'Best' Two-Parameter Model:"; run;
Copyright © SAS Institute, Inc. All Rights Reserved.