<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ROC Curve with Multiple Predictors in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ROC-Curve-with-Multiple-Predictors/m-p/714802#M220717</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312795"&gt;@gabybarber&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Section "&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=statug&amp;amp;docsetTarget=statug_logistic_details33.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;Receiver Operating Characteristic Curves&lt;/A&gt;" of the PROC LOGISTIC documentation uses &lt;EM&gt;probability&lt;/EM&gt; cutpoints. In your example with only two categorical predictors the distinct predicted probabilities correspond to combinations of predictor variable levels (20, as it seems), so you may be interested in both: the probability cutpoint &lt;EM&gt;and&lt;/EM&gt; the combination of SMOKE2 and MATRACE corresponding to each of the 20 sensitivity values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example where this is accomplished. The key is the SCORE statement which I added to the PROC LOGISTIC step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample data for demonstration */

data have;
call streaminit(27182818);
do smoke2=0 to 3;
  do matrace=0 to 4;
    do _n_=1 to 100;
      ppdstatus=rand('bern',logistic( 0.2*(smoke2=1)
                                     +0.5*(smoke2=2)
                                     +1.0*(smoke2=3)
                                     +0.3*(matrace=1)
                                     +0.7*(matrace=2)
                                     +0.4*(matrace=3)
                                     +0.6*(matrace=4)
                                     -3));
      output;
    end;
  end;
end;
run;

/* Perform logistic regression */

ods graphics on;
proc logistic data=have plots=effect plots=roc(id=sensit);
class smoke2 matrace;
model ppdstatus(desc) = smoke2 matrace;
roc 'Smoking with race' smoke2 matrace;
score out=scores outroc=rocdata;
run;
ods graphics off;

/* Combine sensitivities, probability cutpoints and predictor values */

proc sort data=scores out=scores1 nodupkey;
by p_1 smoke2 matrace;
run;

proc sql;
create table want as
select r._sensit_, r._prob_, s.smoke2, s.matrace
from rocdata r left join scores1 s
on _prob_=p_1
order by _sensit_;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs    _SENSIT_     _PROB_    smoke2    matrace

  1     0.11330    0.21221       3         2
  2     0.19704    0.18347       3         4
  3     0.29064    0.16009       2         2
  4     0.38424    0.14311       3         3
  5     0.44335    0.13719       2         4
  6     0.49261    0.13566       3         1
  7     0.52709    0.12538       1         2
  8     0.60591    0.10681       1         4
  9     0.65517    0.10569       2         3
 10     0.69951    0.10555       3         0
 11     0.73399    0.09996       2         1
 12     0.75862    0.08163       1         3
 13     0.81773    0.07709       1         1
 14     0.86700    0.07707       2         0
 15     0.90148    0.06232       0         2
 16     0.92611    0.05909       1         0
 17     0.94089    0.05253       0         4
 18     0.95567    0.03958       0         3
 19     0.98522    0.03728       0         1
 20     1.00000    0.02829       0         0&lt;/PRE&gt;
&lt;P&gt;The _SENSIT_ values,&amp;nbsp;rounded to two decimals, are those found in the ROC plot (not shown here).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see if the code is suitable for your data. Changes might be necessary if the correspondence between probabilities and (SMOKE2, MATRACE) pairs is not 1:1 or perhaps if the join condition &lt;FONT face="courier new,courier"&gt;_prob_=p_1&lt;/FONT&gt; fails because of rounding errors, etc.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jan 2021 20:51:14 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-01-27T20:51:14Z</dc:date>
    <item>
      <title>ROC Curve with Multiple Predictors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ROC-Curve-with-Multiple-Predictors/m-p/714647#M220648</link>
      <description>&lt;P&gt;I am trying to create an ROC curve using maternal race and smoking group as predictors with depression as the outcome. Below is the syntax, we have used to do this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;ods graphics on;&lt;/DIV&gt;&lt;DIV&gt;PROC LOGISTIC DATA=d.pramsv1 plots=effect plots=ROC(id=sensit);&lt;/DIV&gt;&lt;DIV&gt;Class SMOKE2 MATRACE;&lt;/DIV&gt;&lt;DIV&gt;WHERE (ANSAMPLE=1);&lt;/DIV&gt;&lt;DIV&gt;MODEL PPDSTATUS(DESC) = SMOKE2 MATRACE;&lt;/DIV&gt;&lt;DIV&gt;roc 'Smoking with race' SMOKE2 MATRACE;&lt;/DIV&gt;&lt;DIV&gt;RUN;&lt;/DIV&gt;&lt;DIV&gt;ods graphics off;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Our output for the ROC curve has several points labelled with their corresponding sensitivity (see below):&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ROC w_ smoking and maternal race.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53979i589232282D010796/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ROC w_ smoking and maternal race.png" alt="ROC w_ smoking and maternal race.png" /&gt;&lt;/span&gt;&lt;P&gt; Is there a way to determine which cutoffs for the variables correspond to each of these labelled sensitivities?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated! Thanks!&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 27 Jan 2021 16:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ROC-Curve-with-Multiple-Predictors/m-p/714647#M220648</guid>
      <dc:creator>gabybarber</dc:creator>
      <dc:date>2021-01-27T16:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: ROC Curve with Multiple Predictors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ROC-Curve-with-Multiple-Predictors/m-p/714802#M220717</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312795"&gt;@gabybarber&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Section "&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.3&amp;amp;docsetId=statug&amp;amp;docsetTarget=statug_logistic_details33.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;Receiver Operating Characteristic Curves&lt;/A&gt;" of the PROC LOGISTIC documentation uses &lt;EM&gt;probability&lt;/EM&gt; cutpoints. In your example with only two categorical predictors the distinct predicted probabilities correspond to combinations of predictor variable levels (20, as it seems), so you may be interested in both: the probability cutpoint &lt;EM&gt;and&lt;/EM&gt; the combination of SMOKE2 and MATRACE corresponding to each of the 20 sensitivity values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example where this is accomplished. The key is the SCORE statement which I added to the PROC LOGISTIC step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample data for demonstration */

data have;
call streaminit(27182818);
do smoke2=0 to 3;
  do matrace=0 to 4;
    do _n_=1 to 100;
      ppdstatus=rand('bern',logistic( 0.2*(smoke2=1)
                                     +0.5*(smoke2=2)
                                     +1.0*(smoke2=3)
                                     +0.3*(matrace=1)
                                     +0.7*(matrace=2)
                                     +0.4*(matrace=3)
                                     +0.6*(matrace=4)
                                     -3));
      output;
    end;
  end;
end;
run;

/* Perform logistic regression */

ods graphics on;
proc logistic data=have plots=effect plots=roc(id=sensit);
class smoke2 matrace;
model ppdstatus(desc) = smoke2 matrace;
roc 'Smoking with race' smoke2 matrace;
score out=scores outroc=rocdata;
run;
ods graphics off;

/* Combine sensitivities, probability cutpoints and predictor values */

proc sort data=scores out=scores1 nodupkey;
by p_1 smoke2 matrace;
run;

proc sql;
create table want as
select r._sensit_, r._prob_, s.smoke2, s.matrace
from rocdata r left join scores1 s
on _prob_=p_1
order by _sensit_;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs    _SENSIT_     _PROB_    smoke2    matrace

  1     0.11330    0.21221       3         2
  2     0.19704    0.18347       3         4
  3     0.29064    0.16009       2         2
  4     0.38424    0.14311       3         3
  5     0.44335    0.13719       2         4
  6     0.49261    0.13566       3         1
  7     0.52709    0.12538       1         2
  8     0.60591    0.10681       1         4
  9     0.65517    0.10569       2         3
 10     0.69951    0.10555       3         0
 11     0.73399    0.09996       2         1
 12     0.75862    0.08163       1         3
 13     0.81773    0.07709       1         1
 14     0.86700    0.07707       2         0
 15     0.90148    0.06232       0         2
 16     0.92611    0.05909       1         0
 17     0.94089    0.05253       0         4
 18     0.95567    0.03958       0         3
 19     0.98522    0.03728       0         1
 20     1.00000    0.02829       0         0&lt;/PRE&gt;
&lt;P&gt;The _SENSIT_ values,&amp;nbsp;rounded to two decimals, are those found in the ROC plot (not shown here).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see if the code is suitable for your data. Changes might be necessary if the correspondence between probabilities and (SMOKE2, MATRACE) pairs is not 1:1 or perhaps if the join condition &lt;FONT face="courier new,courier"&gt;_prob_=p_1&lt;/FONT&gt; fails because of rounding errors, etc.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 20:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ROC-Curve-with-Multiple-Predictors/m-p/714802#M220717</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-01-27T20:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: ROC Curve with Multiple Predictors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ROC-Curve-with-Multiple-Predictors/m-p/715320#M220930</link>
      <description>Thank you so much! It worked perfectly!&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Jan 2021 15:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ROC-Curve-with-Multiple-Predictors/m-p/715320#M220930</guid>
      <dc:creator>gabybarber</dc:creator>
      <dc:date>2021-01-29T15:28:13Z</dc:date>
    </item>
  </channel>
</rss>

