Skip to content

glm Binomial loglike 0log0 error #42

Closed

Description

@wesm

Original Launchpad bug 680077: https://bugs.launchpad.net/statsmodels/+bug/680077
Reported by: josef-pktd (joep).

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
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.

Activity

  1. wesm commented on Aug 25, 2011

    @wesm
    MemberAuthor

    [ LP comment 1 by: joep, on 2010-11-22 14:58:25.160072+00:00 ]

  2. wesm commented on Aug 25, 2011

    @wesm
    MemberAuthor

    [ LP comment 2 by: joep, on 2010-11-25 14:24:11.728436+00:00 ]

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions