A plot of the fitted model can be produced by many modeling procedures using either the EFFECTPLOT statement or the PLOTS= option in the PROC statement. The predicted (or linear predictor, xβ) values are plotted against one predictor in the model while holding any other predictors at their mean (if continuous) or reference level (if categorical). Limited aspects of the plot can be altered directly in the modeling procedure. Most modifications to the appearance of the produced plot must be made using one of the general methods for altering ODS graphs discussed in this note. The most common modification method is to save the data for the graph and then produce the plot as desired using PROC SGPLOT. Another method that can be used for this type of plot is storing the model and then creating, scoring, and plotting a suitable set of data using the stored model. Both methods are illustrated below for a logistic model.
The following example uses data from a low birth weight study presented by Hosmer and Lemeshow (2000). The probability of low birth weight (low=1) is modeled as a function of several predictors. Of interest is a plot of the predicted probability of low birth weight against the LWT predictor, the last weight of the mother. In the following statements, PROC LOGISTIC fits the desired model and uses the EFFECTPLOT statement to display the fitted model showing the effect of LWT while holding the other predictors fixed. The name of the plot, FitPlot, can be found as described in the referenced note above. This name is used in the ODS OUTPUT statement to save the data that produces the plot.
proc logistic data=lowbirth; class race (ref="1"); model low(event="1") = age lwt race ftv; effectplot fit(x=lwt) / noobs; ods output fitplot=Logfit; run;
The EFFECTPLOT statement in the above PROC LOGISTIC step produces the following graph.
Suppose that you would like the plot to restrict the LWT range to between 100 and 200 and the probability range to between 0 and 0.5. While the YRANGE= option can be used in the EFFECTPLOT statement (or as a suboption in PLOTS=EFFECT) to limit the probability axis range, there is no corresponding option to limit the X axis range.
The following PROC SGPLOT statements produce the desired graph using the saved graph data. You might want to display the contents of the Logfit data set to see the variables that are used in the code below.
The NOAUTOLEGEND option turns off the legend that appears by default in the plot produced by PROC SGPLOT which is not particularly helpful for this plot. The SERIES and BAND statements specify the variables in the Logfit data representing the predicted values and the upper and lower confidence limits of the confidence band. The X axis variable, LWT, appears in this data set with the name _XCONT1. The confidence band is made semi-transparent to allow the grid lines to show from behind. The desired axis ranges are specified in the XAXIS and YAXIS statements. Also specified are options to produce a set of grid lines, specify the Y axis label, and add a small offset, within the plot area, beyond the axis ranges. Finally, suitable titles are specified to display above the plot.
proc sgplot data=Logfit noautolegend; band upper=_uclm lower=_lclm x=_xcont1 / transparency=.3; series y=_predicted x=_xcont1; xaxis values=(100 to 200 by 20) grid offsetmin=.05 offsetmax=.05; yaxis values=(0 to 0.5 by 0.1) grid offsetmin=.05 offsetmax=.05 label="Predicted Probability"; title "Effect of mother's weight from 100 to 200"; title2 "At Age=23.24, FTV=0.794, Race=1"; run;
The plot can also be produced by storing the fitted model and producing suitable plot data. In the following statements, the model is refitted and then saved using the STORE statement. Data for scoring (Inplotdata) are then generated with the other three predictors set at their means or reference levels as done by the EFFECTPLOT statement. Of course, any desired values could be used instead. LWT is varied over the desired range of 100 to 200. PROC PLM then reads the saved model and the data for scoring and produces the predicted values and confidence limits. Since a logistic model uses a link function (the logit link), the ILINK option is needed to produce values on the mean (probability) scale. Without this option, the values would be on the log odds scale. Finally, PROC SGPLOT is used, as above, to produce the desired plot.
proc logistic data=lowbirth; class race (ref="1"); model low(event="1") = age lwt race ftv; store Logmodel; run; data Inplotdata; Age=23.24; FTV=0.794; Race=1; do LWT=100 to 200; output; end; run; proc plm restore=Logmodel; score data=Inplotdata out=Plotdata pred=p uclm=u lclm=l / ilink; run; proc sgplot data=Plotdata noautolegend; band upper=u lower=l x=LWT / transparency=.3; series y=p x=lwt; xaxis values=(100 to 200 by 20) grid offsetmin=.05 offsetmax=.05; yaxis values=(0 to 0.5 by 0.1) grid offsetmin=.05 offsetmax=.05 label="Predicted Probability"; title "Effect of mother's weight from 100 to 200"; title2 "At Age=23.24, FTV=0.794, Race=1"; run;
The resulting plot is essentially identical to the one above. Note that other aspects of the plot can be changed using the capabilities in PROC SGPLOT including changes to color, line pattern, or thickness, adding reference lines or text on the plot, and so on.
Product Family | Product | System | SAS Release | |
Reported | Fixed* | |||
SAS System | SAS/STAT | z/OS | ||
z/OS 64-bit | ||||
OpenVMS VAX | ||||
Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
Microsoft Windows XP 64-bit Edition | ||||
Microsoft® Windows® for x64 | ||||
OS/2 | ||||
Microsoft Windows 8 Enterprise 32-bit | ||||
Microsoft Windows 8 Enterprise x64 | ||||
Microsoft Windows 8 Pro 32-bit | ||||
Microsoft Windows 8 Pro x64 | ||||
Microsoft Windows 8.1 Enterprise 32-bit | ||||
Microsoft Windows 8.1 Enterprise x64 | ||||
Microsoft Windows 8.1 Pro 32-bit | ||||
Microsoft Windows 8.1 Pro x64 | ||||
Microsoft Windows 10 | ||||
Microsoft Windows 95/98 | ||||
Microsoft Windows 2000 Advanced Server | ||||
Microsoft Windows 2000 Datacenter Server | ||||
Microsoft Windows 2000 Server | ||||
Microsoft Windows 2000 Professional | ||||
Microsoft Windows NT Workstation | ||||
Microsoft Windows Server 2003 Datacenter Edition | ||||
Microsoft Windows Server 2003 Enterprise Edition | ||||
Microsoft Windows Server 2003 Standard Edition | ||||
Microsoft Windows Server 2003 for x64 | ||||
Microsoft Windows Server 2008 | ||||
Microsoft Windows Server 2008 R2 | ||||
Microsoft Windows Server 2008 for x64 | ||||
Microsoft Windows Server 2012 Datacenter | ||||
Microsoft Windows Server 2012 R2 Datacenter | ||||
Microsoft Windows Server 2012 R2 Std | ||||
Microsoft Windows Server 2012 Std | ||||
Microsoft Windows Server 2016 | ||||
Microsoft Windows Server 2019 | ||||
Microsoft Windows XP Professional | ||||
Windows 7 Enterprise 32 bit | ||||
Windows 7 Enterprise x64 | ||||
Windows 7 Home Premium 32 bit | ||||
Windows 7 Home Premium x64 | ||||
Windows 7 Professional 32 bit | ||||
Windows 7 Professional x64 | ||||
Windows 7 Ultimate 32 bit | ||||
Windows 7 Ultimate x64 | ||||
Windows Millennium Edition (Me) | ||||
Windows Vista | ||||
Windows Vista for x64 | ||||
64-bit Enabled AIX | ||||
64-bit Enabled HP-UX | ||||
64-bit Enabled Solaris | ||||
ABI+ for Intel Architecture | ||||
AIX | ||||
HP-UX | ||||
HP-UX IPF | ||||
IRIX | ||||
Linux | ||||
Linux for x64 | ||||
Linux on Itanium | ||||
OpenVMS Alpha | ||||
OpenVMS on HP Integrity | ||||
Solaris | ||||
Solaris for x64 | ||||
Tru64 UNIX |
Type: | Usage Note |
Priority: | |
Topic: | Analytics ==> Regression Analytics ==> Statistical Graphics SAS Reference ==> Procedures ==> GEE SAS Reference ==> Procedures ==> GENMOD SAS Reference ==> Procedures ==> LOGISTIC SAS Reference ==> Procedures ==> ORTHOREG SAS Reference ==> Procedures ==> PLM SAS Reference ==> Procedures ==> PROBIT |
Date Modified: | 2020-02-27 16:47:52 |
Date Created: | 2020-02-27 14:52:36 |