<?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: Plot a partial effect from a logistic regression curve in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840647#M332385</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Below is my code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*reference of "Black" race*/
proc logistic data=Mydata desc;
class race(ref='2');
model Outcome=Predictor race / EXPEST;
store outdata;
run;
ods output fitplot =  Fit_outdata;
proc plm source=outdata;
effectplot fit(x=Predictor);
run;
proc sgplot data=Fit_outdata noautolegend;
series x = _XCONT1 y = _PREDICTED / 
lineattrs=(color=VIB pattern=SOLID thickness=3);
band X=_XCONT1 lower=_lclm upper=_uclm / 
fillattrs=(color=VLIGB transparency=.5);
xaxis values = (0 to 3 by 1) 
label='Predictor'
LABELATTRS=(size=14) VALUEATTRS=(size=14);
yaxis grid values = (0 to .8 by .2) label='Outcome' LABELATTRS=(size=14)
VALUEATTRS=(size=14) GRIDATTRS=(color=GrayCA thickness=.0mm);run;

/*reference of "White" race*/
proc logistic data=Mydata desc;
class race(ref='1');
model Outcome=Predictor race / EXPEST;
store outdata;
run;
ods output fitplot =  Fit_outdata;
proc plm source=outdata;
effectplot fit(x=Predictor);
run;
proc sgplot data=Fit_outdata noautolegend;
series x = _XCONT1 y = _PREDICTED / 
lineattrs=(color=VIB pattern=SOLID thickness=3);
band X=_XCONT1 lower=_lclm upper=_uclm / 
fillattrs=(color=VLIGB transparency=.5);
xaxis values = (0 to 3 by 1) 
label='Predictor'
LABELATTRS=(size=14) VALUEATTRS=(size=14);
yaxis grid values = (0 to .8 by .2) label='Outcome' LABELATTRS=(size=14)
VALUEATTRS=(size=14) GRIDATTRS=(color=GrayCA thickness=.0mm);run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see, the only thing that changes is the "ref" for the "race" variable in the "class" statement, yet the lines produced by both effectplot and sgplot (which uses the predicted values from the data produced by the "store" statement) are quite different.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Oct 2022 18:10:05 GMT</pubDate>
    <dc:creator>confooseddesi89</dc:creator>
    <dc:date>2022-10-25T18:10:05Z</dc:date>
    <item>
      <title>Plot a partial effect from a logistic regression curve</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840003#M332133</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am running a multiple logistic regression and would like to produce a plot that depicts the logistic regression curve, with one predictor on the x-axis and the predicted probability of outcome on y-axis, while adjusting for other predictors in the model. I'd prefer to produce such a plot with PROC SGPLOT if possible. Is there a way to do this? Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 18:54:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840003#M332133</guid>
      <dc:creator>confooseddesi89</dc:creator>
      <dc:date>2022-10-21T18:54:43Z</dc:date>
    </item>
    <item>
      <title>Re: Plot a partial effect from a logistic regression curve</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840027#M332142</link>
      <description>&lt;P&gt;It might help to include the code you are currently using for your regression and indicate which predictor you want to use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Likely you need to create an output data set with the predictors and predicted values and the method for that might change depending on how your are doing your regression. Then use that data set, or perhaps a modified version of it, as the input for Proc Sgplot.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 20:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840027#M332142</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-21T20:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Plot a partial effect from a logistic regression curve</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840064#M332162</link>
      <description>&lt;P&gt;Calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could try EFFECTPLOT of PROC LOGISTIC.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rick wrote a couple of blogs about it.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2016/06/22/sas-effectplot-statement.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2016/06/22/sas-effectplot-statement.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2019/02/11/proc-plm-regression-models-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2019/02/11/proc-plm-regression-models-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Oct 2022 09:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840064#M332162</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-10-22T09:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Plot a partial effect from a logistic regression curve</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840366#M332291</link>
      <description>&lt;P&gt;This worked, but I noticed something odd - the line on the plot changes depending on which reference group I choose for a certain class covariate I include in the model. That is, I have the class covariate "race" in the model with the reference as "White," and when I change the reference to "Black," the line becomes steeper. Is there any reason why this may be so? See first graph with reference "White" and second graph with reference "Black." Additionally, when I run the logistic regression analysis and request all plots, the analysis produces the plot (third graph) that appears to depict the effect of the predictor on the outcome at each level of "race." However,&lt;STRONG&gt; I want the mean line &lt;/STRONG&gt;across all races, not a different line for each race (I am not interested in interactions). The point estimate and p-level are the same no matter what I set as the reference race, so I'm not sure why the graphs I'm producing are specifically at the reference level of race.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Graph ref 1.png" style="width: 528px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76506iCEF5C3198A560D13/image-size/large?v=v2&amp;amp;px=999" role="button" title="Graph ref 1.png" alt="Graph ref 1.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Graph ref 2.png" style="width: 528px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76505i606D04A85EF102A4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Graph ref 2.png" alt="Graph ref 2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="for sas forum.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76504iAF5939F7F9CF2376/image-size/large?v=v2&amp;amp;px=999" role="button" title="for sas forum.png" alt="for sas forum.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 20:01:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840366#M332291</guid>
      <dc:creator>confooseddesi89</dc:creator>
      <dc:date>2022-10-24T20:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Plot a partial effect from a logistic regression curve</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840494#M332329</link>
      <description>"I change the reference to "Black," the line becomes steeper. Is there any reason why this may be so?"&lt;BR /&gt;That is because you changed design matrix I think.&lt;BR /&gt;And &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; know more things could give you more explanation .</description>
      <pubDate>Tue, 25 Oct 2022 11:55:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840494#M332329</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-10-25T11:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Plot a partial effect from a logistic regression curve</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840500#M332332</link>
      <description>&lt;P&gt;If you post the code that generated the two graphs, we will be able to answer your questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The predicted values do not depend on the parameterization, so I assume the problem is that the two curves are using different values for the covariates that are not depicted.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 12:27:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840500#M332332</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-10-25T12:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Plot a partial effect from a logistic regression curve</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840647#M332385</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Below is my code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*reference of "Black" race*/
proc logistic data=Mydata desc;
class race(ref='2');
model Outcome=Predictor race / EXPEST;
store outdata;
run;
ods output fitplot =  Fit_outdata;
proc plm source=outdata;
effectplot fit(x=Predictor);
run;
proc sgplot data=Fit_outdata noautolegend;
series x = _XCONT1 y = _PREDICTED / 
lineattrs=(color=VIB pattern=SOLID thickness=3);
band X=_XCONT1 lower=_lclm upper=_uclm / 
fillattrs=(color=VLIGB transparency=.5);
xaxis values = (0 to 3 by 1) 
label='Predictor'
LABELATTRS=(size=14) VALUEATTRS=(size=14);
yaxis grid values = (0 to .8 by .2) label='Outcome' LABELATTRS=(size=14)
VALUEATTRS=(size=14) GRIDATTRS=(color=GrayCA thickness=.0mm);run;

/*reference of "White" race*/
proc logistic data=Mydata desc;
class race(ref='1');
model Outcome=Predictor race / EXPEST;
store outdata;
run;
ods output fitplot =  Fit_outdata;
proc plm source=outdata;
effectplot fit(x=Predictor);
run;
proc sgplot data=Fit_outdata noautolegend;
series x = _XCONT1 y = _PREDICTED / 
lineattrs=(color=VIB pattern=SOLID thickness=3);
band X=_XCONT1 lower=_lclm upper=_uclm / 
fillattrs=(color=VLIGB transparency=.5);
xaxis values = (0 to 3 by 1) 
label='Predictor'
LABELATTRS=(size=14) VALUEATTRS=(size=14);
yaxis grid values = (0 to .8 by .2) label='Outcome' LABELATTRS=(size=14)
VALUEATTRS=(size=14) GRIDATTRS=(color=GrayCA thickness=.0mm);run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you can see, the only thing that changes is the "ref" for the "race" variable in the "class" statement, yet the lines produced by both effectplot and sgplot (which uses the predicted values from the data produced by the "store" statement) are quite different.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 18:10:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840647#M332385</guid>
      <dc:creator>confooseddesi89</dc:creator>
      <dc:date>2022-10-25T18:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Plot a partial effect from a logistic regression curve</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840867#M332475</link>
      <description>&lt;P&gt;Yes, the STORE statement records the reference level, so PROC PLM produces a fit plot for RACE equal to the reference level. Notice that the first call to PROC PLM produces a fit plot that has the footnote "Fit computed at Race=2". In contrast, the second call to PROC PLM produces a fit plot that has the footnote "Fit computed at Race=1". So the two plots are showing different predicted values. The first plot shows the predicted values for Black subjects and the second shows the predicted values for White subjects.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2022 13:15:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840867#M332475</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-10-26T13:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Plot a partial effect from a logistic regression curve</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840870#M332478</link>
      <description>OMG, As Rick pointed out, your Y variable is changed .</description>
      <pubDate>Wed, 26 Oct 2022 13:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Plot-a-partial-effect-from-a-logistic-regression-curve/m-p/840870#M332478</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-10-26T13:22:52Z</dc:date>
    </item>
  </channel>
</rss>

