<?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: Replication of proc logistic in SAS to sklearn.linear_model Logistic Regression has issues in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830112#M328006</link>
    <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Statistical-Procedures/Understanding-the-difference-between-Logistic-regression-results/td-p/735963" target="_blank"&gt;https://communities.sas.com/t5/Statistical-Procedures/Understanding-the-difference-between-Logistic-regression-results/td-p/735963&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try the C option instead?&lt;/P&gt;</description>
    <pubDate>Wed, 24 Aug 2022 15:41:19 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-08-24T15:41:19Z</dc:date>
    <item>
      <title>Replication of proc logistic in SAS to sklearn.linear_model Logistic Regression has issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830077#M327983</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have researched on how to replicate proc logistic from SAS to Logistic Regression in Python and come up with the following observations:&lt;/P&gt;&lt;P&gt;1. SAS uses unpenalized regression and python uses penalty=l2 by default. So I have changed it to penalty=none.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;SAS has default convergence criteria GCONV=1E-8.&amp;nbsp;Python has default value for convergence criteria with tol= 1e-4. I have updated it to&amp;nbsp;1e-8.&lt;/P&gt;&lt;P&gt;3. I have used solver=lbfgs (default value in Python).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to the articles that I have found online, the parameter changes 1 and 2 should get the intercept and coefficient outputs for all model variables similar upto few decimal points in SAS and Python implementations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SAS code:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc logistic DESCENDING data=dataset_name;&lt;/P&gt;&lt;P&gt;model target_var=&amp;amp;modelvariables/ selection = none CLPARM=WALD lackfit RSQ STB ;&lt;/P&gt;&lt;P&gt;output out=result p=pred;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Python code:&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;clf=LogisticRegression(penalty=&lt;/SPAN&gt;&lt;SPAN&gt;'none'&lt;/SPAN&gt;&lt;SPAN&gt;,solver=&lt;/SPAN&gt;&lt;SPAN&gt;'lbfgs'&lt;/SPAN&gt;&lt;SPAN&gt;,tol=&lt;/SPAN&gt;&lt;SPAN&gt;0.00000001&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;clf.fit(X, y)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I compare the SAS and Python outputs, I am having an issue as the intercepts have difference of 2 and one of the variable has the coefficient with opposite sign.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Intercept: SAS (-7.03), Python (-5.21)&lt;/P&gt;&lt;P&gt;Coefficient for one of the variable: SAS (2.56), Python (-2.45)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The remaining variable coefficients match if I round them up to one decimal point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone suggest if any other parameter changes are required in Python?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 14:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830077#M327983</guid>
      <dc:creator>Bond007</dc:creator>
      <dc:date>2022-08-24T14:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: Replication of proc logistic in SAS to sklearn.linear_model Logistic Regression has issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830112#M328006</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Statistical-Procedures/Understanding-the-difference-between-Logistic-regression-results/td-p/735963" target="_blank"&gt;https://communities.sas.com/t5/Statistical-Procedures/Understanding-the-difference-between-Logistic-regression-results/td-p/735963&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try the C option instead?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 15:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830112#M328006</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-08-24T15:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: Replication of proc logistic in SAS to sklearn.linear_model Logistic Regression has issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830117#M328010</link>
      <description>&lt;P&gt;I have tried the C=&lt;SPAN&gt;1e9 option, instead of penalty=none and there are no changes with the output. The issue is not resolved.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 15:50:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830117#M328010</guid>
      <dc:creator>Bond007</dc:creator>
      <dc:date>2022-08-24T15:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Replication of proc logistic in SAS to sklearn.linear_model Logistic Regression has issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830120#M328012</link>
      <description>STB displays the standardized estimate. If you remove the STB from SAS do your answers match?</description>
      <pubDate>Wed, 24 Aug 2022 15:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830120#M328012</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-08-24T15:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replication of proc logistic in SAS to sklearn.linear_model Logistic Regression has issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830126#M328015</link>
      <description>&lt;P&gt;The SAS logistic regression output gives both the estimate and standard estimate columns, along with few other columns (Error, Chi-Square, Pr &amp;gt; ChiSq).&lt;BR /&gt;I am attempting to accurately replicate the SAS model using Python. So for this case, SAS model is non-editable.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Aug 2022 16:08:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830126#M328015</guid>
      <dc:creator>Bond007</dc:creator>
      <dc:date>2022-08-24T16:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Replication of proc logistic in SAS to sklearn.linear_model Logistic Regression has issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830266#M328063</link>
      <description>You got different sign from "&amp;nbsp;SAS (2.56), Python (-2.45)" , &lt;BR /&gt;that means you model different level of Y between SAS and Python, &lt;BR /&gt;Try remove "DESCENDING&amp;nbsp;" option from PROC LOGISTIC ,&lt;BR /&gt; or try "target_var(event='0')" or "target_var(event='1')"</description>
      <pubDate>Thu, 25 Aug 2022 11:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830266#M328063</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-08-25T11:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Replication of proc logistic in SAS to sklearn.linear_model Logistic Regression has issues</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830880#M328326</link>
      <description>&lt;P&gt;I have used the following code and the results from SAS and Python Logistic Regression are a match.&lt;/P&gt;
&lt;DIV&gt;&lt;SPAN&gt;clf=LogisticRegression(penalty=&lt;/SPAN&gt;&lt;SPAN&gt;'none',&lt;/SPAN&gt;&lt;SPAN&gt;solver=&lt;/SPAN&gt;&lt;SPAN&gt;'newton-cg'&lt;/SPAN&gt;&lt;SPAN&gt;,tol=&lt;/SPAN&gt;&lt;SPAN&gt;0.00000001&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;clf.fit(X, y)&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 29 Aug 2022 12:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replication-of-proc-logistic-in-SAS-to-sklearn-linear-model/m-p/830880#M328326</guid>
      <dc:creator>Bond007</dc:creator>
      <dc:date>2022-08-29T12:47:22Z</dc:date>
    </item>
  </channel>
</rss>

