Implement likelihood ratio test for Cox regression
This commit is contained in:
parent
eb0d520d95
commit
642d0d4e4f
@ -1,5 +1,5 @@
|
|||||||
# scipy-yli: Helpful SciPy utilities and recipes
|
# 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
|
# 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
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -520,11 +520,13 @@ class RegressionResult:
|
|||||||
else:
|
else:
|
||||||
right_col.append(('F:', format(f_result.statistic, '.2f')))
|
right_col.append(('F:', format(f_result.statistic, '.2f')))
|
||||||
right_col.append(('p (F):', fmt_p(f_result.pvalue, PValueStyle.VALUE_ONLY)))
|
right_col.append(('p (F):', fmt_p(f_result.pvalue, PValueStyle.VALUE_ONLY)))
|
||||||
elif self.ll_null:
|
else:
|
||||||
# Otherwise report likelihood ratio test as overall test
|
# Otherwise report likelihood ratio test as overall test
|
||||||
|
right_col.append(('LL-Model:', format(self.ll_model, '.2f')))
|
||||||
|
|
||||||
|
if self.ll_null:
|
||||||
lrtest_result = self.lrtest_null()
|
lrtest_result = self.lrtest_null()
|
||||||
|
|
||||||
right_col.append(('LL-Model:', format(self.ll_model, '.2f')))
|
|
||||||
right_col.append(('LL-Null:', format(self.ll_null, '.2f')))
|
right_col.append(('LL-Null:', format(self.ll_null, '.2f')))
|
||||||
if html:
|
if html:
|
||||||
right_col.append(('<i>p</i> (LR):', fmt_p(lrtest_result.pvalue, PValueStyle.VALUE_ONLY | PValueStyle.HTML)))
|
right_col.append(('<i>p</i> (LR):', fmt_p(lrtest_result.pvalue, PValueStyle.VALUE_ONLY | PValueStyle.HTML)))
|
||||||
@ -917,7 +919,7 @@ def regress(
|
|||||||
elif hasattr(result, 'llnull'):
|
elif hasattr(result, 'llnull'):
|
||||||
ll_null = result.llnull
|
ll_null = result.llnull
|
||||||
elif model_class is sm.PHReg:
|
elif model_class is sm.PHReg:
|
||||||
ll_null = None
|
ll_null = model.loglike([0 for _ in result.params])
|
||||||
else:
|
else:
|
||||||
# Construct null (intercept-only) model
|
# Construct null (intercept-only) model
|
||||||
#result_null = model_class.from_formula(formula=dep + ' ~ 1', data=df).fit()
|
#result_null = model_class.from_formula(formula=dep + ' ~ 1', data=df).fit()
|
||||||
|
Loading…
Reference in New Issue
Block a user