Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
marker (=0 and 1) and
group (=1 and 2).
How to make two ROC-curve ON THE SAME plot? I watched a lot to the internet, but, unfortunately, did't understand the explanation. I would be very grateful for the help! So, how to put a group variable here? (P.S. And also get AUC with confidence intervals.)
ods graphics on;
proc logistic data=d plots=EFFECT plots=ROC;
model marker (event='1') = Y;
ods graphics off;
P.S. Now I'll add a sample.
Y – it's person's weight
group (=1 and 2) where 1 is male, 2 – female
marker (=0 and 1) where 1 means that weight is surplus and 0 means that weight is normal.
I need to get two ROC-curves (for men and women) on the same plot for comparison their.
–
–
–
You have two independent samples (men and women), and want to compare the ROC curves calculated from each sample. As I understand it from
http://support.sas.com/kb/45/339.html
, SAS cannot compare ROC curves from independent samples in one PROC step. You have to do the work yourself.
The process is:
Run PROC LOGISTIC to compute the ROC statistics (sensitivity/specificity at each cut point) and AUCs with standard errors, for each sample.
Build a plot of the ROC statistics, overlaying the two curves.
Compute a test statistic and p-value from the AUCs.
Below is my attempt at an example. I'm not promising this is correct, but it's my implementation of my understanding of the information in the support note. Please read the support note.
Sample data. I still don't understand your data, so I made some that I do understand. Data for 5 females and 6 males. Each person has a score on some diagnostic test, and a disease status (1/0).
data have;
input Sex $1. Test Disease;
cards;
F 10 0
F 20 0
F 30 1
F 40 0
F 50 1
M 10 0
M 20 1
M 30 0
M 40 1
M 50 1
M 60 1
Run PROC logistic, and output the statistics. I used a BY statement rather than running separate PROC steps for males and females.
ods output ROCassociation=AUCs(where=(ROCmodel="Test"));
proc logistic data=have plots(only)=roc;
model Disease(event='1') = Test
/outroc=RocStats(where=(_source_="Test"))
roc 'Test' Test;
by Sex;
ods output close;
Use SGPLOT to plot the overlaid ROC curves. I'm using 9.3 so need to use ODS graphics statement to force a square plot. 9.4 introduced aspect=1 option to SGPLOT. It's a straight-forward plot, reminds me how much I love SGPLOT and GTL. I don't think I'll ever go back to GPLOT.
ods graphics / height=480px width=480px;
proc sgplot data=RocStats;
xaxis values=(0 to 1 by 0.25) grid offsetmin=.05 offsetmax=.05;
yaxis values=(0 to 1 by 0.25) grid offsetmin=.05 offsetmax=.05;
lineparm x=0 y=0 slope=1 / transparency=.7;
series x=_1mspec_ y=_sensit_ / group=Sex;
Compute the test statistics. The support note said this is a large-sample test. The test statistic follows chi-square distribution with 1 degree of freedom.
data AUCtest(keep=AreaMale StdErrMale AreaFemale StdErrFemale ChiSq Prob);
set AUCs (keep=Sex Area StdErr
where=(Sex='M')
rename=(Area=AreaMale StdErr=StdErrMale)
set AUCs (keep=Sex Area StdErr
where=(Sex='F')
rename=(Area=AreaFemale StdErr=StdErrFemale)
ChiSq=(AreaMale-AreaFemale)**2/(StdErrMale**2 + StdErrFemale**2);
Prob=1-probChi(ChiSq,1);
format Prob pvalue6.;
Again, don't take any of this as truth. Use at your own risk, I'm in the learning phase also.
–
–
See the ROC statement and ROCCONTRAST statement. Good example in the SAS docs.
You didn't give sample data, but I believe you would want something like:
proc logistic data=d plots=EFFECT plots=ROC /nofit;
model marker (event='1') = Y Group;
roc 'Y' Y;
roc 'Group' Group;
roccontrast reference('Group') / estimate e;
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.