<?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 Simulated ROC Curve in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Simulated-ROC-Curve/m-p/237614#M18516</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;BR /&gt;I need to simulate simulate 4 ROC curves going from 0.15 0.25 0.3 0.35 are above the reference line of a random model.&lt;/P&gt;&lt;P&gt;Could you help me with this ? I need to create these graphs to illustrate a logistic regression model.&lt;BR /&gt;Thanks&lt;/P&gt;&lt;P&gt;Jorge Ribeiro&lt;/P&gt;</description>
    <pubDate>Thu, 03 Dec 2015 16:26:22 GMT</pubDate>
    <dc:creator>jorgesribeiro</dc:creator>
    <dc:date>2015-12-03T16:26:22Z</dc:date>
    <item>
      <title>Simulated ROC Curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulated-ROC-Curve/m-p/237614#M18516</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;BR /&gt;I need to simulate simulate 4 ROC curves going from 0.15 0.25 0.3 0.35 are above the reference line of a random model.&lt;/P&gt;&lt;P&gt;Could you help me with this ? I need to create these graphs to illustrate a logistic regression model.&lt;BR /&gt;Thanks&lt;/P&gt;&lt;P&gt;Jorge Ribeiro&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2015 16:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulated-ROC-Curve/m-p/237614#M18516</guid>
      <dc:creator>jorgesribeiro</dc:creator>
      <dc:date>2015-12-03T16:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Simulated ROC Curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulated-ROC-Curve/m-p/353295#M18517</link>
      <description>&lt;P&gt;I don't know what you mean by "&lt;SPAN&gt;going from 0.15 0.25 0.3 0.35", but you can simulate data for a logistic regression model by using the example at "&lt;A href="http://blogs.sas.com/content/iml/2014/06/27/simulate-many-samples-from-a-logistic-regression-model.html" target="_self"&gt;Simulate many samples from a logistic regression model,"&lt;/A&gt;&amp;nbsp;which is taken from the book &lt;EM&gt;Simulating Data with SAS&lt;/EM&gt; (Wicklin&amp;nbsp;2013). &amp;nbsp;There are lots of ways to get distinct ROC curves. One way is to misspecify the model in the simulation. &amp;nbsp;That's what the following code does: the model is constructed&amp;nbsp;to depend on X1, X2, and X3, but the MODEL statement only specifies X1 and X2.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* program from 
   http://blogs.sas.com/content/iml/2014/06/27/simulate-many-samples-from-a-logistic-regression-model.html */
%let N = 150;                                   /* N = sample size */
%let NumSamples = 4;                            /* number of samples */
proc iml;
call randseed(1);
X = j(&amp;amp;N, 4, 1);                               /* X[,1] is intercept */
/* 1. Read design matrix for X or assign X randomly.
   For this example, x1 ~ U(0,1) and x2 ~ N(0,2)  */
X[,2] = randfun(&amp;amp;N, "Uniform"); 
X[,3] = randfun(&amp;amp;N, "Normal", 0, 2);
error = randfun(&amp;amp;N, "Normal", 0, 1); 
/* Logistic model with parameters {2, -4, 1} */
beta = {2, -4, 1, -1};
 
/* create output data set. Output data during each loop iteration.     */
varNames = {"SampleID" "y"} || ("x1":"x3");           /* 1st col is ID */
Out = j(&amp;amp;N,1) || X;                /* matrix to store simulated data   */
create LogisticData from Out[c=varNames];
y = j(&amp;amp;N,1);                       /* allocate response vector         */
do i = 1 to &amp;amp;NumSamples;           /* the simulation loop              */
   X[,4] = i*error;                    /* magnitude of error */
   eta = X*beta;                       /* 2. linear model */
   mu = logistic(eta);                 /* 3. transform by inverse logit */
   Out[,1] = i;                         /* update value of SampleID    */
   call randgen(y, "Bernoulli", mu);    /* 4. simulate binary response */
   Out[,2] = y;
   append from Out;                     /* 5. output this sample       */
end;                               /* end loop                         */
close LogisticData; 
quit;

proc logistic data=LogisticData noprint outest=PE;
   by SampleId;
   model y(Event='1') = x1 x2 / outroc = outROC;
run;

proc sgplot data=outROC;
   series x=_1MSPEC_ y=_SENSIT_ / group=SampleID;
   lineparm slope=1 x=0 y=0;    /* reference line */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/8537iCCD00018D779FA00/image-size/medium?v=1.0&amp;amp;px=-1" border="0" alt="SGPlot5.png" title="SGPlot5.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You could do something similar with real data: leave out variables that explain the model to get different ROC curves.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2017 16:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulated-ROC-Curve/m-p/353295#M18517</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-04-25T16:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Simulated ROC Curve</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulated-ROC-Curve/m-p/353687#M18522</link>
      <description>&lt;P&gt;Assuming you are talking abou the area under the ROC curve being those amounts above the reference line (where AUC=0.5), you can do pretty well by using the following data set from one of the examples in the PROC LOGISTIC documentation and, as Rick suggests, using various models as shown:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data Neuralgia;&lt;BR /&gt; input Treatment $ Sex $ Age Duration Pain $ @@;&lt;BR /&gt; datalines;&lt;BR /&gt; Placebo Female 68 1 No TrtA Female 69 12 No &lt;BR /&gt; Placebo Male 66 26 Yes TrtB Male 67 23 No &lt;BR /&gt; TrtA Female 71 12 No TrtB Male 77 1 Yes&lt;BR /&gt; TrtA Male 71 17 Yes Placebo Female 65 29 No &lt;BR /&gt; TrtB Female 66 12 No TrtB Male 75 21 Yes&lt;BR /&gt; TrtA Female 64 17 No Placebo Female 70 13 Yes&lt;BR /&gt; Placebo Male 70 1 Yes Placebo Female 68 27 Yes&lt;BR /&gt; TrtA Female 64 30 No TrtB Male 70 22 No &lt;BR /&gt; TrtB Female 78 1 No TrtA Male 67 10 No &lt;BR /&gt; TrtB Male 75 30 Yes TrtB Male 80 21 Yes&lt;BR /&gt; TrtA Male 70 12 No Placebo Female 67 30 No&lt;BR /&gt; TrtB Male 70 1 No TrtB Female 77 16 No&lt;BR /&gt; Placebo Male 78 12 Yes TrtB Female 76 9 Yes&lt;BR /&gt; Placebo Male 66 4 Yes TrtA Female 69 18 Yes&lt;BR /&gt; TrtA Male 78 15 Yes Placebo Female 64 1 Yes&lt;BR /&gt; Placebo Female 72 27 No TrtA Female 72 25 No&lt;BR /&gt; TrtB Female 65 7 No TrtB Male 59 29 No&lt;BR /&gt; Placebo Male 67 17 Yes TrtA Male 69 1 No&lt;BR /&gt; Placebo Female 67 1 Yes TrtB Female 69 42 No&lt;BR /&gt; TrtA Female 74 1 No Placebo Female 79 20 Yes&lt;BR /&gt; TrtB Male 74 16 No TrtB Female 65 14 No&lt;BR /&gt; TrtB Female 67 28 No TrtA Male 76 25 Yes&lt;BR /&gt; TrtB Female 72 50 No TrtB Female 69 24 No&lt;BR /&gt; TrtA Female 63 27 No Placebo Male 60 26 Yes&lt;BR /&gt; TrtA Male 62 42 No TrtA Female 67 11 No&lt;BR /&gt; Placebo Male 74 4 No TrtA Male 75 6 Yes&lt;BR /&gt; TrtB Male 66 19 No Placebo Male 68 11 Yes&lt;BR /&gt; TrtA Male 70 28 No TrtA Male 65 15 No&lt;BR /&gt; Placebo Male 83 1 Yes Placebo Female 72 11 Yes&lt;BR /&gt; Placebo Male 77 29 Yes TrtA Female 69 3 No&lt;BR /&gt; ;&lt;BR /&gt; ods select roccurve(persist);&lt;BR /&gt; proc logistic data=Neuralgia plots(only)=roc;&lt;BR /&gt; class Treatment Sex;&lt;BR /&gt; model Pain(event="No") = Treatment Sex Treatment*Sex Age Duration ;&lt;BR /&gt; run;&lt;BR /&gt; proc logistic data=Neuralgia plots(only)=roc;&lt;BR /&gt; class Treatment Sex;&lt;BR /&gt; model Pain(event="No") = Treatment Sex Treatment*Sex ;&lt;BR /&gt; run;&lt;BR /&gt; proc logistic data=Neuralgia plots(only)=roc;&lt;BR /&gt; class Treatment Sex;&lt;BR /&gt; model Pain(event="No") = Treatment ;&lt;BR /&gt; run;&lt;BR /&gt; proc logistic data=Neuralgia plots(only)=roc;&lt;BR /&gt; class Treatment Sex;&lt;BR /&gt; model Pain(event="No") = Sex ;&lt;BR /&gt; run;&lt;BR /&gt; ods select all;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 13:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulated-ROC-Curve/m-p/353687#M18522</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2017-04-26T13:41:24Z</dc:date>
    </item>
  </channel>
</rss>

