I am trying to implement the Python version of this 'R' code to compare 2 or more Logistic Regression models by finding deviance statistics
anova(LogisticModel.1, LogisticModel.2)
which gives an output like this
There is an statsmodels implementation of anova testing for linear models which work as follows:
from statsmodels.formula.api import ols
from statsmodels.stats.anova import anova_lm
m01 = ols('sales~adverts', data=df).fit()
m02 = ols('sales~adverts+airplay', data=df).fit()
m03 = ols('sales~adverts+airplay+attract', data=df).fit()
anovaResults = anova_lm(m01, m02, m03)
print(anovaResults)
I have calculated the residual df, residual deviance , Deviance described in the Logistic Regression table by doing manual calculations, but I wonder if there is anything to do this automatically in Python using any Library.
A similar question has been asked here but it remains unanswered .