You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: NegativeBinomial and new count models override callback #3895
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.
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.
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.
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)
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.
Activity
josef-pkt commentedon Aug 29, 2017
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.
josef-pkt commentedon Aug 29, 2017
as workaround
callback = lambda *x: xworks for basinhopping.(But basinhopping does not converge to the minimum in the ZIGP example, and does not have a invertible hessian)
BUG: quickfix callback in countmodels, see statsmodels#3895,
BUG: quickfix callback in countmodels, see statsmodels#3895,
BUG: quickfix callback in countmodels, see statsmodels#3895,
BUG: quickfix callback in countmodels, see statsmodels#3895,
bashtage commentedon Jul 30, 2026
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.