In statsmodels ordinary least squares have likelihood ratio test implemented
OLSResults.compare_lr_test(restricted)
That is not true for the generalized linear model (GLM). I tried to implemtent copyng the OLS implementation:
from scipy import stats
llf_full = results.llf
llf_restr = results_res.llf
df_full = results.df_resid
df_restr = results_res.df_resid
lrdf = (df_restr - df_full)
lrstat = -2*(llf_restr - llf_full)
lr_pvalue = stats.chi2.sf(lrstat, df=lrdf)
lr_pvalue
it looks strightforward, but the fact that this is not implemented make me suspicious. Is this correct?
I don't see any problem.
Generalized Linear Models are Maximum Likelihood models, if the scale is the one implied by the family.
statsmodels.GLM doesn't currently implement Quasi-Likelihood methods where the scale can deviate from those of the underlying family, e.g. overdispersed Poisson, so the Likelihood Ratio test can be applied.
implementation detail: compare_lr_test
was supposed to be added for all LikelihoodModels, but I didn't check whether it's correct (or raises exception) for all models that inherit from it.