Skip to content

BUG: NegativeBinomial and new count models override callback #3895

Closed

Description

@josef-pkt

related: #3706

The count models except for Poisson use a hardcoded callback=lambda x: x in the super(...).fit call.
This breaks the use of basinhopping, which has 3 arguments in the callback according to the exception traceback.

Either we drop this or we fix the callback to callback=lambda *x, **kwds: x, kwds
(only positional arguments are in basinhopping AFAICS, but we could as well be generic and add **kwds.

from #3755 (comment) :

I guess you copied the callback from NegativeBinomial.fit. Poisson fit doesn't override callback.
I have no idea why NegativeBinomial.fit overrides the user provided or None callback, except those things can easily slip through a code review.

The reason might be that DiscreteModel uses the callback (if None) to check for perfect separation which should only be for binary models right now. I don't see any other use of the callback.

Activity

  1. added this to the 0.9 milestone on Aug 29, 2017
  2. josef-pkt commented on Aug 29, 2017

    @josef-pkt
    MemberAuthor

    The perfect separation callback should move down to BinaryModel, which does not have it's own fit.
    One solution is to add a get_callback method, that returns None except in BinaryModels.

    aside perfect separation callback is only added if callback argument is None.

  3. josef-pkt commented on Aug 29, 2017

    @josef-pkt
    MemberAuthor

    as workaround callback = lambda *x: x works for basinhopping.
    (But basinhopping does not converge to the minimum in the ZIGP example, and does not have a invertible hessian)

  4. modified the milestones: 0.9, 0.10 on Oct 3, 2017
  5. bashtage commented on Jul 30, 2026

    @bashtage
    Member

    Fixed by commit 6b2b656 (2017-09-06): NegativeBinomial/GeneralizedPoisson/NegativeBinomialP/zero-inflated models now use def callback(*x): return x instead of a hardcoded single-arg lambda. Closing as fixed.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions