<?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 plotting logit function. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520752#M4083</link>
    <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a difficult time plotting the logit (of finding the syntax to plot the logit) of an outcome against a continuous variable.&lt;/P&gt;&lt;P&gt;I am doing this in order to check for linearity for a logistical regression. I have a binary outcome that I modeled against a continuous variable and another binary variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 12 Dec 2018 11:32:05 GMT</pubDate>
    <dc:creator>TakakuraMD</dc:creator>
    <dc:date>2018-12-12T11:32:05Z</dc:date>
    <item>
      <title>plotting logit function.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520752#M4083</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a difficult time plotting the logit (of finding the syntax to plot the logit) of an outcome against a continuous variable.&lt;/P&gt;&lt;P&gt;I am doing this in order to check for linearity for a logistical regression. I have a binary outcome that I modeled against a continuous variable and another binary variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 11:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520752#M4083</guid>
      <dc:creator>TakakuraMD</dc:creator>
      <dc:date>2018-12-12T11:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: plotting logit function.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520770#M4089</link>
      <description>&lt;P&gt;Welcome to the SAS communities. Do you simply want to plot the logit function?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data logit;
   do p=0.01 to 0.99 by 0.01;
      logit=log(p/(1-p));
      output;
   end;
run;

title "Plotting the logit function";
proc sgplot data=logit;
   series x=p y=logit;
   xaxis grid;
   yaxis grid label="logit(p)";
run;
title;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Dec 2018 12:19:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520770#M4089</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-12T12:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: plotting logit function.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520782#M4095</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you for your response. I wanted to do this for my data set.&lt;BR /&gt;&lt;BR /&gt;My data set consists of a binary outcome (dead or alive)&lt;BR /&gt;&lt;BR /&gt;1 continuous variable (age)&lt;BR /&gt;&lt;BR /&gt;1 binary variable Having a heart disease (yes or no)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I want to plot the logit of dead or alive vs the variable age and check for linearity. I think some call this checking for "linear in the logit"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Dec 2018 12:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520782#M4095</guid>
      <dc:creator>TakakuraMD</dc:creator>
      <dc:date>2018-12-12T12:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: plotting logit function.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520791#M4097</link>
      <description>&lt;P&gt;Try a Google search for "sas empirical logit plot". Quite a few examples.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post example data if you want a usable code answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 13:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520791#M4097</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-12T13:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: plotting logit function.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520796#M4098</link>
      <description>Thank you,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Found this very helpful. You guys are the best.&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Dec 2018 13:22:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520796#M4098</guid>
      <dc:creator>TakakuraMD</dc:creator>
      <dc:date>2018-12-12T13:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: plotting logit function.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520798#M4099</link>
      <description>&lt;P&gt;Anytime. If you found your answer, please mark the thread as accepted to help other users navigate the forum &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, please post in this thread again if you have questions.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 13:25:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520798#M4099</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-12T13:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: plotting logit function.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520807#M4101</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;might give you an hand, He wrote a blog about it before.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;good_bad=ifn(outcome='dead',1,0);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=have;&lt;/P&gt;
&lt;P&gt;loess x=age y=good_bad;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 13:33:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520807#M4101</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-12-12T13:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: plotting logit function.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520846#M4112</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/250890"&gt;@TakakuraMD&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One method described in&amp;nbsp;&lt;A href="http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470582472.html" target="_blank" rel="nofollow noopener noreferrer"&gt;Hosmer/Lemeshow: Applied Logistic Regression, 3rd ed.&lt;/A&gt;, p. 95 f. (in the 2nd edition: p. 99) involves&amp;nbsp;creating a 4-level categorical version of the continuous variable (based on the quartiles) and using this in place of the original variable in a logistic regression model including the other model variables ("heart disease" in your example).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create test data for demonstration */

data have;
call streaminit(31415926);
do subjid=1 to 500;
  age=int(rand('uniform',18,75));
  heartdis=rand('bern',age/100-0.15);
  p=logistic(-4.56+0.0567*age+1.23*heartdis);
  dead=rand('bern',p);
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is an implementation of this method for variable AGE in the above dataset HAVE:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Compute age quartiles */

proc summary data=have;
var age;
output out=_qtls(drop=_type_ _freq_) min=_min q1=_q1 median=_q2 q3=_q3 max=_max;
run;

/* Create a categorical version of AGE with four levels */

data _tmpana(rename=(agecat=age));
if _n_=1 then set _qtls;
set have;
if age&amp;gt;_q3 then agecat=4;
else if age&amp;gt;_q2 then agecat=3;
else if age&amp;gt;_q1 then agecat=2;
else if age&amp;gt;.   then agecat=1;
else agecat=.;
drop age;
run;

/* Create a model using the new categorical variable AGE in place of the continuous original */

ods output ParameterEstimates=est(keep=Variable ClassVal0 Estimate where=(Variable="age"));
proc logistic data = _tmpana desc;
class heartdis(ref='0') age(ref='1') / param=ref;
model dead = heartdis age;
run;

/* Combine quartile midpoints and corresponding model coefficients */

data _midp;
set est(drop=Variable);
if _n_=1 then do;
  set _qtls;
  age=(_min+_q1)/2;
  _coeff=0;
  output;
end;
select(ClassVal0);
  when('2') do;
              age=(_q1+_q2)/2;
              _coeff=Estimate;
              output;
            end;
  when('3') do;
              age=(_q2+_q3)/2;
              _coeff=Estimate;
              output;
            end;
  when('4') do;
              age=(_q3+_max)/2;
              _coeff=Estimate;
              output;
            end;
  otherwise;
end;
keep _coeff age;
run;

/* Plot coefficients vs. quartile midpoints to check the linearity assumption */

proc sgplot data=_midp;
series x=age y=_coeff / markers;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The resulting plot supports the assumption that the model is&amp;nbsp;linear in the logit for variable AGE:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="linearity_check.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25628iF04576819EB6142F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="linearity_check.png" alt="linearity_check.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Dec 2018 15:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/plotting-logit-function/m-p/520846#M4112</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-12-12T15:13:53Z</dc:date>
    </item>
  </channel>
</rss>

