To compute the pseudo R2 of my GLM model, I need the null deviance.
formula: 1-(deviance/null.deviance)
The model deviance is given in the model.summary() output, but how do I compute/access the null deviance?
My code example is:
import statsmodels.formula.api as smf
import statsmodels.api as sm
# generate random dataframe
df = pd.DataFrame(np.random.randint(0,100,size=(100, 3)), columns=list('ABC'))
# negative binomial regression
model = smf.glm(formula = "c ~ a + b", data=df, family=sm.families.NegativeBinomial()).fit()
model.summary()
Actually, figured it out:
model.null_deviance
model.deviance