Update OrdinalLogit test

This commit is contained in:
RunasSudo 2023-12-31 18:34:54 +11:00
parent f42c152019
commit b837ecc3a3
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 4 additions and 4 deletions

View File

@ -1,5 +1,5 @@
# scipy-yli: Helpful SciPy utilities and recipes
# Copyright © 2022 Lee Yingtong Li (RunasSudo)
# Copyright © 2022–2023 Lee Yingtong Li (RunasSudo)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@ -44,7 +44,7 @@ def test_ordinallogit_ucla():
expected_summary = ''' Ordinal Logistic Regression Results
==========================================================
Dep. Variable: apply | No. Observations: 400
Model: Ordinal Logit | Df. Model: 5
Model: Ordinal Logit | Df. Model: 3
Date: {0:%Y-%m-%d} | Df. Residuals: 395
Time: {0:%H:%M:%S} | Pseudo : 0.03
Std. Errors: Non-Robust | LL-Model: -358.51
@ -62,7 +62,7 @@ somewhat likely/very likely 4.30 (2.72 - 5.88) <0.001*
------------------------------------------------------------'''.format(result.fitted_dt)
assert result.summary() == expected_summary
assert result._repr_html_() == '<table><caption>Ordinal Logistic Regression Results</caption><tr><th>Dep. Variable:</th><td>apply</td><th>No. Observations:</th><td>400</td></tr><tr><th>Model:</th><td>Ordinal Logit</td><th>Df. Model:</th><td>5</td></tr><tr><th>Date:</th><td>{0:%Y-%m-%d}</td><th>Df. Residuals:</th><td>395</td></tr><tr><th>Time:</th><td>{0:%H:%M:%S}</td><th>Pseudo <i>R</i><sup>2</sup>:</th><td>0.03</td></tr><tr><th>Std. Errors:</th><td>Non-Robust</td><th>LL-Model:</th><td>-358.51</td></tr><tr><th></th><td></td><th>LL-Null:</th><td>-370.60</td></tr><tr><th></th><td></td><th><i>p</i> (LR):</th><td>&lt;0.001*</td></tr></table><table><tr><th></th><th style="text-align:center"><i>β</i></th><th colspan="3" style="text-align:center">(95% CI)</th><th style="text-align:center"><i>p</i></th></tr><tr><th>pared</th><td>1.05</td><td style="padding-right:0">(0.53</td><td>–</td><td style="padding-left:0">1.57)</td><td style="text-align:left">&lt;0.001*</td></tr><tr><th>public</th><td>-0.06</td><td style="padding-right:0">(-0.64</td><td>–</td><td style="padding-left:0">0.53)</td><td style="text-align:left"><span style="visibility:hidden">=</span>0.84</td></tr><tr><th>gpa</th><td>0.62</td><td style="padding-right:0">(0.10</td><td>–</td><td style="padding-left:0">1.13)</td><td style="text-align:left"><span style="visibility:hidden">=</span>0.02*</td></tr><tr><th>(Cutoffs)</th><td></td><td style="padding-right:0"></td><td></td><td style="padding-left:0"></td><td></td></tr><tr><td style="text-align:right;font-style:italic">unlikely/somewhat likely</td><td>2.20</td><td style="padding-right:0">(0.68</td><td>–</td><td style="padding-left:0">3.73)</td><td style="text-align:left"><span style="visibility:hidden">=</span>0.005*</td></tr><tr><td style="text-align:right;font-style:italic">somewhat likely/very likely</td><td>4.30</td><td style="padding-right:0">(2.72</td><td>–</td><td style="padding-left:0">5.88)</td><td style="text-align:left">&lt;0.001*</td></tr></table>'.format(result.fitted_dt)
assert result._repr_html_() == '<table><caption>Ordinal Logistic Regression Results</caption><tr><th>Dep. Variable:</th><td>apply</td><th>No. Observations:</th><td>400</td></tr><tr><th>Model:</th><td>Ordinal Logit</td><th>Df. Model:</th><td>3</td></tr><tr><th>Date:</th><td>{0:%Y-%m-%d}</td><th>Df. Residuals:</th><td>395</td></tr><tr><th>Time:</th><td>{0:%H:%M:%S}</td><th>Pseudo <i>R</i><sup>2</sup>:</th><td>0.03</td></tr><tr><th>Std. Errors:</th><td>Non-Robust</td><th>LL-Model:</th><td>-358.51</td></tr><tr><th></th><td></td><th>LL-Null:</th><td>-370.60</td></tr><tr><th></th><td></td><th><i>p</i> (LR):</th><td>&lt;0.001*</td></tr></table><table><tr><th></th><th style="text-align:center"><i>β</i></th><th colspan="3" style="text-align:center">(95% CI)</th><th style="text-align:center"><i>p</i></th></tr><tr><th>pared</th><td>1.05</td><td style="padding-right:0">(0.53</td><td>–</td><td style="padding-left:0">1.57)</td><td style="text-align:left">&lt;0.001*</td></tr><tr><th>public</th><td>-0.06</td><td style="padding-right:0">(-0.64</td><td>–</td><td style="padding-left:0">0.53)</td><td style="text-align:left"><span style="visibility:hidden">=</span>0.84</td></tr><tr><th>gpa</th><td>0.62</td><td style="padding-right:0">(0.10</td><td>–</td><td style="padding-left:0">1.13)</td><td style="text-align:left"><span style="visibility:hidden">=</span>0.02*</td></tr><tr><th>(Cutoffs)</th><td></td><td style="padding-right:0"></td><td></td><td style="padding-left:0"></td><td></td></tr><tr><td style="text-align:right;font-style:italic">unlikely/somewhat likely</td><td>2.20</td><td style="padding-right:0">(0.68</td><td>–</td><td style="padding-left:0">3.73)</td><td style="text-align:left"><span style="visibility:hidden">=</span>0.005*</td></tr><tr><td style="text-align:right;font-style:italic">somewhat likely/very likely</td><td>4.30</td><td style="padding-right:0">(2.72</td><td>–</td><td style="padding-left:0">5.88)</td><td style="text-align:left">&lt;0.001*</td></tr></table>'.format(result.fitted_dt)
def test_brant_ucla():
"""Compare RegressionModel.brant with R brant library for UCLA example at https://stats.oarc.ucla.edu/r/dae/ordinal-logistic-regression/"""

View File

@ -1063,7 +1063,7 @@ class OrdinalLogit(RegressionModel):
Ordinal Logistic Regression Results
==========================================================
Dep. Variable: apply | No. Observations: 400
Model: Ordinal Logit | Df. Model: 5
Model: Ordinal Logit | Df. Model: 3
Date: 2022-12-02 | Df. Residuals: 395
Time: 21:30:38 | Pseudo : 0.03
Std. Errors: Non-Robust | LL-Model: -358.51