Hello,
I'm running a binomial regression and I can't figure out why the fitted model deviance is "nan"
Model = sm.GLM(endog=success_fail, exog=design, family=sm.families.Binomial()).fit()
Model.summary()
Generalized Linear Model Regression ResultsDep. Variable: | ['success', 'fail'] | No. Observations: | 15351 |
---|
Model: | GLM | Df Residuals: | 14832 |
---|
Model Family: | Binomial | Df Model: | 518 |
---|
Link Function: | logit | Scale: | 1.0 |
---|
Method: | IRLS | Log-Likelihood: | nan |
---|
Date: | Fri, 07 Oct 2016 | Deviance: | nan |
---|
Time: | 11:13:53 | Pearson chi2: | 1.89e+04 |
---|
No. Iterations: | 20 | | |
---|
Particularly because I tried to calculate the deviance myself (as below), and I got not nan, but 19645.24, which seems reasonable. I am running similar models for slightly different data, and none of them have this problem, so I can't tell where the nan is coming from. I wonder if it is influencing the fit? :
pi = Model.fittedvalues
success = np.array(success_fail['success'])
fail = np.array(success_fail['fail'])
n = np.array(success_fail.sum(axis=1))
success_dev = success*np.log(success/(pi*n) + 1e-200)
fail_dev = fail*np.log(fail/((1-pi)*n) + 1e-200)
print 2*(success_dev.sum() + fail_dev.sum())
Thank you,
Rachel