Is there python function for comparing two or more Logistic Regression models using anova?
Asked Answered
G

0

6

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 enter image description here

There is an 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)

which gives an output like enter image description here

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 .

Gonyea answered 28/6, 2020 at 11:47 Comment(1)
I believe rmstmppr awsered it hereTopsail

© 2022 - 2024 — McMap. All rights reserved.