<?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: Manually calculating logistic regression probabilities in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820301#M323765</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185515"&gt;@zeynep&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185515"&gt;@zeynep&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried Probability = 1 / [1 +exp (-(B0 + b1X))]&amp;nbsp;and inputted the values from the “Estimate” column and the values for my variables, but the resulting probability was not the same with what I got in IP_1 column.&lt;/P&gt;
&lt;P&gt;I tried using reference coding instead of effect coding to get the estimates, and then calculated the probability, but again it was not the same with IP_1 value.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your formula is correct. There is the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/n13u4gq0z9qwo4n15f6e6bg8mv79.htm" target="_blank" rel="noopener"&gt;LOGISTIC function&lt;/A&gt; to simplify the code a bit. But either way I get a result that is close to&amp;nbsp;&lt;SPAN&gt;IP_1 (the remaining rounding error could almost certainly be avoided by using more precise parameter values from an output dataset), regardless of the parameterization of VAR3 and VAR4:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;47    data _null_;
48    p=logistic(-7.0333-0.0111*21-0.00089*1897+1.2178-0.076);
49    put p;
50    p=logistic(-6.4624-0.0111*21-0.00089*1897+0.6089-0.038);
51    put p;
52    run;

0.0004043077
0.0004043077&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jun 2022 18:55:10 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2022-06-24T18:55:10Z</dc:date>
    <item>
      <title>Manually calculating logistic regression probabilities</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820298#M323763</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am using proc logistic (binary logit model). I would like to see if I can get the same predicted probability IP_1 values that proc logistic provides, if I do the calculation manually using regression equation.&lt;/P&gt;&lt;P&gt;I tried Probability = 1 / [1 +exp (-(B0 + b1X))]&amp;nbsp;and inputted the values from the “Estimate” column and the values for my variables, but the resulting probability was not the same with what I got in IP_1 column.&lt;/P&gt;&lt;P&gt;I tried using reference coding instead of effect coding to get the estimates, and then calculated the probability, but again it was not the same with IP_1 value.&lt;/P&gt;&lt;P&gt;How can I get to IP_1 = 0.000406?&lt;/P&gt;&lt;P&gt;Here is an example with the values of the variables, and coefficients.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;var1&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;var2&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;var3&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;var4&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;IP_1&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;manual cal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coding&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Parameter&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;DF&lt;/TD&gt;&lt;TD&gt;Estimate&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Intercept&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;-7.0333&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;var3&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1.2178&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;var4&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;-0.076&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;var2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;-0.00089&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;var1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;-0.0111&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc logistic data=mydata desc outmodel= model plots(only)=roc PLOTS(MAXPOINTS=NONE) plots=effect;&lt;BR /&gt;class var3 (ref='1') var4 (ref='1') / param = ref ;&lt;BR /&gt;model target_var = var1 var2 var3 var4 / lackfit firth ctable pprob=(0.0010, 0.0015, 0.002, 0.0025, 0.003, 0.004) maxiter=100;&lt;BR /&gt;output out=preds predprobs=individual;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Zeynep&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 18:25:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820298#M323763</guid>
      <dc:creator>zeynep</dc:creator>
      <dc:date>2022-06-24T18:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Manually calculating logistic regression probabilities</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820301#M323765</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185515"&gt;@zeynep&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185515"&gt;@zeynep&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tried Probability = 1 / [1 +exp (-(B0 + b1X))]&amp;nbsp;and inputted the values from the “Estimate” column and the values for my variables, but the resulting probability was not the same with what I got in IP_1 column.&lt;/P&gt;
&lt;P&gt;I tried using reference coding instead of effect coding to get the estimates, and then calculated the probability, but again it was not the same with IP_1 value.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your formula is correct. There is the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.2/lefunctionsref/n13u4gq0z9qwo4n15f6e6bg8mv79.htm" target="_blank" rel="noopener"&gt;LOGISTIC function&lt;/A&gt; to simplify the code a bit. But either way I get a result that is close to&amp;nbsp;&lt;SPAN&gt;IP_1 (the remaining rounding error could almost certainly be avoided by using more precise parameter values from an output dataset), regardless of the parameterization of VAR3 and VAR4:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;47    data _null_;
48    p=logistic(-7.0333-0.0111*21-0.00089*1897+1.2178-0.076);
49    put p;
50    p=logistic(-6.4624-0.0111*21-0.00089*1897+0.6089-0.038);
51    put p;
52    run;

0.0004043077
0.0004043077&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 18:55:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820301#M323765</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-06-24T18:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Manually calculating logistic regression probabilities</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820303#M323767</link>
      <description>Thank you @FreelanceReinhard for your reply.&lt;BR /&gt;var3 and var4 are binary variables and in this example, their values are 0. That's why I multiplied their coefficients with 0 in the equation just like multiplying var1 and var2 coefficients with their values. Can you explain why it's incorrect? What if the values of var3 and var4 were 1, would you still calculate as p=logistic(-6.4624-0.0111*21-0.00089*1897+0.6089-0.038)?</description>
      <pubDate>Fri, 24 Jun 2022 19:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820303#M323767</guid>
      <dc:creator>zeynep</dc:creator>
      <dc:date>2022-06-24T19:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: Manually calculating logistic regression probabilities</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820308#M323770</link>
      <description>&lt;P&gt;PROC LOGISTIC now has the CODE statement so you can have the scoring code created for you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Compare your code to that code is one good way to check this process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here's a post that illustrates an end to end check for the calculations:&lt;/P&gt;
&lt;P&gt;Raw data to run the code is here: (neuralgia data set)&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_logistic_examples02.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/statug/statug_logistic_examples02.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;And post showing example:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Statistical-Procedures/How-to-determine-logistic-regression-formula-from-estimates/td-p/120780" target="_blank"&gt;https://communities.sas.com/t5/Statistical-Procedures/How-to-determine-logistic-regression-formula-from-estimates/td-p/120780&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 19:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820308#M323770</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-24T19:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Manually calculating logistic regression probabilities</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820309#M323771</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;.&lt;BR /&gt;I have just tried the code in the post you shared and I got the same value with my manual calculation (0.000129594) both of which are not close to IP_1. Below are the values. The code inputs 0 for var3 and var4 just like I do in my manual calculation, but the pred prob gets close to IP_1 only if we input 1 just like @FreelanceReinhard did. I am not clear on why we would multiply by 1 instead of 0, when the values of the variables are 0. Any thoughts?&lt;BR /&gt;&lt;BR /&gt;IP_1 myformula&lt;BR /&gt;0.000405819 0.000129594</description>
      <pubDate>Fri, 24 Jun 2022 19:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820309#M323771</guid>
      <dc:creator>zeynep</dc:creator>
      <dc:date>2022-06-24T19:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Manually calculating logistic regression probabilities</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820310#M323772</link>
      <description>&lt;P&gt;Post the Effect Coding matrix please.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 19:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820310#M323772</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-24T19:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Manually calculating logistic regression probabilities</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820311#M323773</link>
      <description>&lt;P&gt;Here is the class levels. Does the last column mean if the value is 0 in the data, input them as 1? If that's the case, how can I flip them?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Class Level Information&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Class&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;TD&gt;Design&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Variables&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;var3&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;var4&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 24 Jun 2022 19:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820311#M323773</guid>
      <dc:creator>zeynep</dc:creator>
      <dc:date>2022-06-24T19:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Manually calculating logistic regression probabilities</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820312#M323774</link>
      <description>Note that your value and design code are flipped... 0 maps to 1 and 1 maps to 0.</description>
      <pubDate>Fri, 24 Jun 2022 20:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820312#M323774</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-24T20:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Manually calculating logistic regression probabilities</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820313#M323775</link>
      <description>&lt;P&gt;You've specified the reference level is 1, which means that is coded as 0.&lt;/P&gt;
&lt;P&gt;Sounds like you want the opposite, you can just remove the reference specification.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc logistic data=mydata desc outmodel= model plots(only)=roc PLOTS(MAXPOINTS=NONE) plots=effect;
class var3 &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;(ref='1')&lt;/STRONG&gt;&lt;/FONT&gt; var4 &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;(ref='1')&lt;/STRONG&gt;&lt;/FONT&gt; / param = ref ;
model target_var = var1 var2 var3 var4 / lackfit firth ctable pprob=(0.0010, 0.0015, 0.002, 0.0025, 0.003, 0.004) maxiter=100;
output out=preds predprobs=individual;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jun 2022 20:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820313#M323775</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-24T20:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Manually calculating logistic regression probabilities</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820316#M323778</link>
      <description>&lt;P&gt;Actually I wasn't using the reference specification in my original code and still 0 and 1 were flipped, but if I do (ref='0') that gives the same probabilities with IP_1. Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 20:23:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820316#M323778</guid>
      <dc:creator>zeynep</dc:creator>
      <dc:date>2022-06-24T20:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: Manually calculating logistic regression probabilities</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820351#M323791</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/185515"&gt;@zeynep&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;var3 and var4 are binary variables and in this example, their values are 0. That's why I multiplied their coefficients with 0 in the equation just like multiplying var1 and var2 coefficients with their values. Can you explain why it's incorrect? What if the values of var3 and var4 were 1, would you still calculate as p=logistic(-6.4624-0.0111*21-0.00089*1897+0.6089-0.038)?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Remember that also character variables on a nominal scale can be used as categorical predictors. For those it is obvious that in the regression equation their values (such as "Caucasian", "Yes", "Divorced") must be replaced by the numeric values of the corresponding design variables (whose creation is triggered by the CLASS statement). If a predictor is listed in the CLASS statement, its design variables are&amp;nbsp;&lt;EM&gt;always&lt;/EM&gt;&amp;nbsp;used. No exceptions are made for predictors whose original values happen to be numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, in the case of effect coding of VAR3 and VAR4 with the &lt;FONT face="courier new,courier"&gt;ref='1'&lt;/FONT&gt; option you would look at the design matrix (cf. table "Class Level Information" in your PROC LOGISTIC output or the generic example in the documentation: "&lt;A href="https://documentation.sas.com/doc/en/statug/15.2/statug_introcom_sect012.htm" target="_blank" rel="noopener"&gt;Other Parameterizations&lt;/A&gt;", first table). There you would find out that if the values of VAR3 and VAR4 were 1 (i.e., equal to their respective reference levels), the corresponding design variable values in the regression equation would be &lt;STRONG&gt;−1&lt;/STRONG&gt;, leading to the calculation&amp;nbsp;&lt;FONT face="courier new,courier" size="4"&gt;p=logistic(-6.4624-0.0111*21-0.00089*1897&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;-&lt;/FONT&gt;&lt;/STRONG&gt;0.6089&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;+&lt;/FONT&gt;&lt;/STRONG&gt;0.038)&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That said, a special feature of&amp;nbsp;&lt;EM&gt;binary&lt;/EM&gt; variables with values 0 and 1 is that they may be treated as continuous variables (by removing them from the CLASS statement), in which case handling them "just like" VAR1 and VAR2 would be correct. The results will be exactly the same as if they are used in the CLASS statement with a parameterization assigning 0 to 0 and 1 to 1 in the design variables. This is not surprising because then the design variable and the original predictor are mathematically equal.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jun 2022 08:52:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Manually-calculating-logistic-regression-probabilities/m-p/820351#M323791</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-06-25T08:52:53Z</dc:date>
    </item>
  </channel>
</rss>

