Repository navigation
BUG/ENH fix llnull, extra kwds to recreate model #1610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cf79587
TST: add failing test, bug #1221
josef-pkt 52e628f
REF/ENH: add `_init_keys` to recreate model closes #1221 closes #1609
josef-pkt a644b7f
TST: change smoke test results negbin geometric llnull
josef-pkt 55fa677
TST: TestProbitCG.test_conf_int use relative error (intermittend test…
josef-pkt 05116c2
REF: add _get_init_kwds overwrite in CountModel
josef-pkt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you just attach exposure and offset here without going through the init_keys business?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_methodin 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nice point of
_init_keysis that we don't care what keywords names where added.Whether they are
exposureorweightsorloglike_methodorfixed_params_maskororderor ..., 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_keysor 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) + offsetto avoid the repeated sum).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.