Add documentation for RegressionResult.brant

This commit is contained in:
RunasSudo 2022-12-02 22:03:25 +11:00
parent b2a72a8ef8
commit 957ef9f3fc
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 37 additions and 4 deletions

View File

@ -6,17 +6,20 @@ Functions
.. autofunction:: yli.logit_then_regress .. autofunction:: yli.logit_then_regress
.. autoclass:: yli.OrdinalLogit
.. autoclass:: yli.PenalisedLogit .. autoclass:: yli.PenalisedLogit
.. autofunction:: yli.regress .. autofunction:: yli.regress
.. autofunction:: yli.regress_bootstrap
.. autofunction:: yli.vif .. autofunction:: yli.vif
Result classes Result classes
-------------- --------------
.. autoclass:: yli.regress.BrantResult
:members:
.. autoclass:: yli.regress.CategoricalTerm .. autoclass:: yli.regress.CategoricalTerm
:members: :members:

View File

@ -256,7 +256,33 @@ class RegressionResult:
return bf01.invert() return bf01.invert()
def brant(self): def brant(self):
# TODO: Documentation """
Perform the Brant test for the parallel regression assumption in ordinal regression
Applicable when the model was fitted using :class:`OrdinalLogit`.
:rtype: :class:`BrantResult`
**Example:**
.. code-block::
df = pd.DataFrame(...)
model = yli.regress(yli.OrdinalLogit, df, 'apply', 'pared + public + gpa', exp=False)
model.brant()
.. code-block:: text
χ² df p
Omnibus 4.34 3 0.23
pared 0.13 1 0.72
public 3.44 1 0.06
gpa 0.18 1 0.67
The output shows the result of the Brant test. For example, for the omnibus test of the parallel regression assumption across all independent variables, the *χ*:sup:`2` statistic is 4.34, the *χ*:sup:`2` distribution has 3 degrees of freedom, and the test is not significant, with *p* value 0.23.
**Reference:** Brant R. Assessing proportionality in the proportional odds model for ordinal logistic regression. *Biometrics*. 1990;46(4):11718. `doi:10.2307/2532457 <https://doi.org/10.2307/2532457>`_
"""
df = self.df() df = self.df()
if df is None: if df is None:
@ -1070,7 +1096,11 @@ def _wald_test(param_names, params, formula, vcov, df):
return lmr.wald_test(formula, cov_p=vcov, use_f=False, scalar=True) return lmr.wald_test(formula, cov_p=vcov, use_f=False, scalar=True)
class BrantResult: class BrantResult:
# TODO: Documentation """
Result of a Brant test for ordinal regression
See :meth:`RegressionResult.brant`.
"""
def __init__(self, tests): def __init__(self, tests):
#: Results for Brant test on each coefficient (*Dict[str, ChiSquaredResult]*) #: Results for Brant test on each coefficient (*Dict[str, ChiSquaredResult]*)