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.

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 Mar 29, 2016 at 14:31 "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 Mar 29, 2016 at 21:48 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 Mar 29, 2016 at 22:06

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.

    Everything works fine! Quentin, You are very Generous! Many thanks!!! (I think SAS unnecessarily complicated at solving simple medstat question.) P.S. Unfortunately, my "reputation" is not enough to evaluate your answer. – Beginner Mar 30, 2016 at 8:48 Glad it helped. Even if you don't have enough rep to vote, I think you can still accept the answer by clicking the check mark next to it (which will earn both of us some rep :). Agree SAS decision to put ROC computations inside PROC LOGISTIC rather than in a separate dedicated PROC ROC definitely causes limitations. – Quentin Mar 30, 2016 at 9:08

    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;     
                    Agreed, that is not what you want because you have two independent samples.  The above would work if you had one sample, and wanted to compare two predictors.  I'll add an answer.
    – Quentin
                    Mar 30, 2016 at 2:31
            

    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.