Repository navigation
BUG/ENH fix llnull, extra kwds to recreate model - #1610
Conversation
There was a problem hiding this comment.
Couldn't you just attach exposure and offset here without going through the init_keys business?
There was a problem hiding this comment.
I don't like adding ifs to a superclass that checks attributes that are only available in some subclasses.
I thought about just adding the method to the CountModels.
But I want a generic solution. Here I don't need any special code for loglike_method in NegativeBinomial except registering the keyword.
plus, we will need the same for other things see #1093 (e.g. diagnostic tests)
There was a problem hiding this comment.
You have the generic solution, but you don't need it. I'm not saying take out init_keys, but you don't really need it here to check for parameters that are attached as attributes already.
There was a problem hiding this comment.
We need it. Generically, we don't know which attributes have been attached from the model.__init__ signature.
This should also automatically catch weights in WLS, rho in GLSAR, ...
I got started with this a few days ago because I added an attribute in a Poisson subclass that broke llnul called by summary(). I fixed that in a different way, but it's going to happen all the time.
The alternative to a generic solution, requires lot's of code that handles special cases.
There was a problem hiding this comment.
Thinking about it a bit, it's really not all that generic. You still need to know what keys you're looking for in _init_keys.
There was a problem hiding this comment.
Yes that's a bug. My point is that only CountModels will have an exposure, so it should be a CountModel 'feature'. NegativeBinomial came after Poisson, so there's not the right amount of code sharing yet in CountModel.
There was a problem hiding this comment.
The nice point of _init_keys is that we don't care what keywords names where added.
Whether they are exposure or weights or loglike_method or fixed_params_mask or order or ..., the code is generic as long as the original argument value (after data handling (*)) has been attached to the model instance as an attribute.
(*) to get ahead: I'm thinking of this for internal usage as for the use cases in #1093 where we don't need the formula or pandas metainformation.
I haven't seen or thought about any use case that might need pandas or formula information. That' much further down the road if we need it.
There was a problem hiding this comment.
I understand the reason for _init_keys. But you've hard-coded exposure here. That's not generic. Admittedly, it's because we log it in the __init__ and store the logged version. So...either fix that as part of this PR too (and add logs whenever exposure is used / fix the hard-coded exposure or offset only) or only check for exposure in CountModel. That's my main point. My other point is that if you're going to introduce those changes in this (bug fix) PR, then go the whole nine yards and implement the _get_keys or whatever. This could've been a quick two line fix to close the bug but now I'd like to see the other issues fixed in this PR, if we're going to start the other changes.
There was a problem hiding this comment.
I don't want to fix log(exposure) in this PR. it's not backwards compatible and needs better design (for example merge _offset_all = np.exp(exposure) + offset to avoid the repeated sum).
There was a problem hiding this comment.
Why is it not backwards compatible? Nothing the user does would changed. I doubt there are people out there with pickled exposure variables, but we could add a warning.
This PR either 1) fixes the bug its for only 2) Goes all the way and solve 3-4 outstanding, related issues or 3) Solves 1.5 issues and adds a hack for checking exposure in models where we don't necessarily need to.
Right now it's 3, but it'd make more sense to do 1 or 2 I think. In any case, we've talked about this PR more than it warrants.
|
Ok, I figured out a way to avoid adding a special countmodel llnul |
BUG/ENH fix llnull, extra kwds to recreate model
BUG/ENH fix llnull, extra kwds to recreate model
This adds
_init_keystobase.Modeland fixesllnulin discrete modelsincludes one test precision adjustment for
TestProbitCG.test_conf_int(use relative precision)llnull
BUG #1221 missing
exposurein llnul of countmodelsBUG #1608 missing
loglike_methodin llnul of NegativeBinomialrecreating models see #1093
no test yet for nb1 versus nb2 with exposure