glm Binomial loglike 0log0 error

Bug #680077 reported by joep
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
statsmodels
Fix Released
High
Unassigned

Bug Description

reported by Sol 2010-11-22

>>> sm.GLM(y.astype(float),
             sm.add_constant(XYP.astype(float), prepend=True),
             family=sm.families.Binomial()).fit()
Traceback (most recent call last):
  File "<pyshell#37>", line 3, in <module>
    family=sm.families.Binomial()).fit()
  File "c:\josef\eclipsegworkspace\statsmodels-josef-experimental-gsoc\scikits\statsmodels\glm.py", line 388, in fit
    returned a nan. This could be a boundary problem and should be reported."
ValueError: The first guess on the deviance function returned a nan. This could be a boundary problem and should be reported.

Revision history for this message
joep (josef-pktd) wrote :
Revision history for this message
joep (josef-pktd) wrote :

see http://bazaar.launchpad.net/~josef-pktd/statsmodels/statsmodels-josef-experimental-gsoc/revision/2194

I added 1e-200 to all instances of a*log(b) that looked like `a` and `b` could be zero.

The test cases of Sol, with either zero successes or zero failures finish now without raising an exception.

I will attach the new test script that also includes now the zero failure case.

The only disadvantage, I can see is that we create an additional temporary array, but that might be unavoidable in any case.

Ready for review

joep (josef-pktd)
Changed in statsmodels:
importance: Undecided → High
milestone: none → 0.3.0
status: New → Fix Committed
joep (josef-pktd)
Changed in statsmodels:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.