A plot of the ROC curve for the fitted model can be produced by either the PLOTS=ROC option in the PROC LOGISTIC statement, or the ROC statement, or by the OUTROC= option in the MODEL statement. Limited aspects of the ROC plot can be specified by options in the ROCOPTIONS= option in the PROC LOGISTIC statement. 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 following shows the most common modification method which saves the data for the graph and then produces the plot as desired using PROC SGPLOT.
In this example, BY group processing is used in PROC LOGISTIC to fit a model to two groups of data which produces two separate ROC plots. However, you want a single plot showing both ROC curves. You also want to specify the plot title and different axis labels than are used by PROC LOGISTIC.
If a statistical comparison of the areas under the ROC curves is desired, see the testing method discussed and illustrated in this note.
The name of the ROC graph produced by PROC LOGISTIC can be found in "ODS Graphics" in the Details section of the PROC LOGISTIC documentation. There, you find that the name of the ROC graph is ROCCurve. In the code below, that name is used to save the graph data in data set ROCdata using the ODS OUTPUT statement.
data flydata; input block entry lat lng n r @@; if block<=2 then Group=1; else Group=2; datalines; 1 14 1 1 8 2 1 16 1 2 9 1 1 7 1 3 13 9 1 6 1 4 9 9 1 13 2 1 9 2 1 15 2 2 14 7 1 8 2 3 8 6 1 5 2 4 11 8 1 11 3 1 12 7 1 12 3 2 11 8 1 2 3 3 10 8 1 3 3 4 12 5 1 10 4 1 9 7 1 9 4 2 15 8 1 4 4 3 19 6 1 1 4 4 8 7 2 15 5 1 15 6 2 3 5 2 11 9 2 10 5 3 12 5 2 2 5 4 9 9 2 11 6 1 20 10 2 7 6 2 10 8 2 14 6 3 12 4 2 6 6 4 10 7 2 5 7 1 8 8 2 13 7 2 6 0 2 12 7 3 9 2 2 16 7 4 9 0 2 9 8 1 14 9 2 1 8 2 13 12 2 8 8 3 12 3 2 4 8 4 14 7 3 7 1 5 7 7 3 13 1 6 7 0 3 8 1 7 13 3 3 14 1 8 9 0 3 4 2 5 15 11 3 10 2 6 9 7 3 3 2 7 15 11 3 9 2 8 13 5 3 6 3 5 16 9 3 1 3 6 8 8 3 15 3 7 7 0 3 12 3 8 12 8 3 11 4 5 8 1 3 16 4 6 15 1 3 5 4 7 12 7 3 2 4 8 16 12 4 9 5 5 15 8 4 4 5 6 10 6 4 12 5 7 13 5 4 1 5 8 15 9 4 15 6 5 17 6 4 6 6 6 8 2 4 14 6 7 12 5 4 7 6 8 15 8 4 13 7 5 13 2 4 8 7 6 13 9 4 3 7 7 9 9 4 10 7 8 6 6 4 2 8 5 12 8 4 11 8 6 9 7 4 5 8 7 11 10 4 16 8 8 15 7 ; proc logistic data=flydata plots(only)=roc; by Group; model r/n = entry; ods output roccurve=ROCdata; run;
The PLOTS= option in the above PROC LOGISTIC statements produces the following ROC plots for the two groups.
In PROC SGPLOT, the ASPECT=1 option requests a square plot which is customary for an ROC plot in which both axes use the [0,1] range. The desired axis labels and tick points are specified in the XAXIS and YAXIS statements. Also specified is an option to produce a set of grid lines and a small offset, within the plot area, above and below the [0,1] range. The LINEPARM statement draws the diagonal line and the SERIES statement specifies the variables to plot and the variable identifying the groups. The INSET statement writes the individual group AUC (area under the ROC curve) values inside the plot area. Finally, a suitable title is provided in the TITLE statement.
proc sgplot data=ROCdata aspect=1; xaxis label="False Positive Fraction" values=(0 to 1 by 0.25) grid offsetmin=.05 offsetmax=.05; yaxis label="True Positive Fraction" values=(0 to 1 by 0.25) grid offsetmin=.05 offsetmax=.05; lineparm x=0 y=0 slope=1 / transparency=.3 lineattrs=(color=gray); series x=_1mspec_ y=_sensit_ / group=Group; inset ("Group 1 AUC" = "0.6891" "Group 2 AUC" = "0.7038") / border opaque position=bottomright; title "ROC curves for both groups"; run;
The plot produced by the above code is shown below. Note that it closely resembles the appearance of an ROC plot produced by PROC LOGISTIC.
Product Family | Product | System | SAS Release | |
Reported | Fixed* | |||
SAS System | N/A | Microsoft Windows 2000 Professional | ||
Microsoft Windows NT Workstation | ||||
Microsoft Windows 2000 Server | ||||
Microsoft Windows 2000 Advanced Server | ||||
Microsoft Windows 2000 Datacenter Server | ||||
Microsoft Windows 95/98 | ||||
Microsoft Windows 8.1 Pro 32-bit | ||||
Microsoft Windows 8.1 Pro x64 | ||||
Microsoft Windows 8.1 Enterprise x64 | ||||
SAS Cloud | ||||
Microsoft Windows 8.1 Enterprise 32-bit | ||||
Microsoft® Windows® for x64 | ||||
OS/2 | ||||
Microsoft Windows XP 64-bit Edition | ||||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | ||||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | ||||
Microsoft® Windows® for 64-Bit Itanium-based Systems | ||||
Microsoft Windows Server 2012 R2 Datacenter | ||||
Microsoft Windows Server 2012 R2 Std | ||||
Microsoft Windows Server 2008 R2 | ||||
Microsoft Windows 8 Pro x64 | ||||
Microsoft Windows 8 x64 | ||||
Microsoft Windows 8 Pro 32-bit | ||||
Microsoft Windows 8 Enterprise 32-bit | ||||
Microsoft Windows 8 Enterprise x64 | ||||
Microsoft Windows 10 | ||||
Microsoft Windows 7 | ||||
Macintosh | ||||
Macintosh on x64 | ||||
Chrome Web Browser | ||||
Android Operating System | ||||
Apple Mobile Operating System | ||||
OpenVMS VAX | ||||
N/A | ||||
IBM AS/400 | ||||
z/OS | ||||
z/OS 64-bit | ||||
Solaris for x64 | ||||
Tru64 UNIX | ||||
Solaris | ||||
OpenVMS Alpha | ||||
OpenVMS on HP Integrity | ||||
Linux for x64 | ||||
Linux on Itanium | ||||
Linux for AArch64 | ||||
IRIX | ||||
Linux | ||||
HP-UX | ||||
HP-UX IPF | ||||
AIX | ||||
64-bit Enabled Solaris | ||||
ABI+ for Intel Architecture | ||||
64-bit Enabled HP-UX | ||||
64-bit Enabled AIX | ||||
Teradata on Linux | ||||
Cloud Foundry | ||||
Netezza TwinFin 64-bit SMP Hosts | ||||
Netezza TwinFin 32bit blade | ||||
Netezza TwinFin 64-bit S-Blades | ||||
Netezza TwinFin 32-bit SMP Hosts | ||||
DB2 Universal Database on Linux x64 | ||||
Aster Data nCluster on Linux x64 | ||||
DB2 Universal Database on AIX | ||||
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 for x64 | ||||
Microsoft Windows Server 2012 Datacenter | ||||
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 |
Type: | Usage Note |
Priority: | |
Topic: | SAS Reference ==> Procedures ==> LOGISTIC Analytics ==> Categorical Data Analysis Analytics ==> Statistical Graphics |
Date Modified: | 2020-03-11 10:15:31 |
Date Created: | 2020-02-26 10:43:40 |