0
votes

SAS (9.4) dataset (d) includes 3 variables: Y, 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;

run;

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.

2
This doesn't make sense to me yet. Your Dependent variable is Marker, where 1 means overweight and 0 means normal. Your predictor variable Y is weight. So you want to see if weight (Y) is a good predictor of being overweight (Marker)? And see if the ROC curves are the same for men and women? - Quentin
Do you have the same number of men and women? - Quentin
"And see if the ROC curves are the same for men and women?" YES! "Do you have the same number of men and women?" NO! - Beginner
I think I'm not really understanding, but I'll try to attempt another answer, either tonight or tomorrow night. Sounds like you want to over-lay two ROC curves from independent samples (Men and Women). This support note has an approach that looks promising: support.sas.com/kb/45/339.html - Quentin

2 Answers

1
votes

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:

  1. Run PROC LOGISTIC to compute the ROC statistics (sensitivity/specificity at each cut point) and AUCs with standard errors, for each sample.
  2. Build a plot of the ROC statistics, overlaying the two curves.
  3. 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;

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;
run;
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;
run;

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.;
run;

Again, don't take any of this as truth. Use at your own risk, I'm in the learning phase also.

0
votes

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;     
run;