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
BUG: Allow all appropriate links in a Family #7816
Merged
Merged
Conversation
This file contains 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
unrelated random failure, missing seed |
josef-pkt
reviewed
Oct 21, 2021
(F.InverseGaussian, inverse_gaussian_links), | ||
(F.NegativeBinomial, negative_bionomial_links), | ||
(F.Tweedie, tweedie_links) | ||
]) |
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.
define the list outside, then it doesn't need to be repeated
cases = [....
Thanks, I think this looks good. closes #1509 |
The list of links in a Family (Poisson, Gaussian, etc.) included the "aliased" link type instead of the primary link type, when possible. Poisson, for example, include link.log instead of link.Log. Using the aliased class in the family link list results in suprising behavior like this: ``` In [1]: import statsmodels.genmod.families as F In [2]: import statsmodels.genmod.families.links as L In [3]: F.Poisson(link=L.log()) Out[3]: <statsmodels.genmod.families.family.Poisson at 0x111da15b0> In [4]: F.Poisson(link=L.Log()) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-4-47050bb1e621> in <module> ----> 1 F.Poisson(link=L.Log()) ~/Documents/old/statsmodels/statsmodels/genmod/families/family.py in __init__(self, link) 399 if link is None: 400 link = L.log() --> 401 super(Poisson, self).__init__(link=link, variance=Poisson.variance) 402 403 def _resid_dev(self, endog, mu): ~/Documents/old/statsmodels/statsmodels/genmod/families/family.py in __init__(self, link, variance) 83 raise TypeError(warnmssg) 84 else: ---> 85 self.link = link 86 self.variance = variance 87 ~/Documents/old/statsmodels/statsmodels/genmod/families/family.py in _setlink(self, link) 64 if not validlink: 65 errmsg = "Invalid link for family, should be in %s. (got %s)" ---> 66 raise ValueError(errmsg % (repr(self.links), link)) 67 68 def _getlink(self): ValueError: Invalid link for family, should be in [<class 'statsmodels.genmod.families.links.log'>, <class 'statsmodels.genmod.families.links.identity'>, <class 'statsmodels.genmod.families.links.sqrt'>]. (got <statsmodels.genmod.families.links.Log object at 0x111e7efa0>) ``` L.log works but L.Log doesn't, even though L.log is an simply an "alias" of L.Log. By changing the family link lists to use "unaliased" classes (the parent classes of the various aliases) both L.log and L.Log work as expected.
all green and LGTM, merging @tncowart Thank you for the PR |
bashtage
pushed a commit
to bashtage/statsmodels
that referenced
this pull request
Nov 5, 2021
BUG: Allow all appropriate links in a Family
bashtage
added a commit
that referenced
this pull request
Nov 5, 2021
BACKPORT: Merge pull request #7816 from tncowart/unalias_links
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The list of links in a Family (Poisson, Gaussian, etc.) included the
"aliased" link type instead of the primary link type, when possible.
Poisson, for example, include link.log instead of link.Log.
Using the aliased class in the family link list results in suprising
behavior like this:
L.log works but L.Log doesn't, even though L.log is an simply an "alias"
of L.Log.
By changing the family link lists to use "unaliased" classes (the parent
classes of the various aliases) both L.log and L.Log work as expected.
NumPy's guide.
Notes:
needed for doc changes.
then show that it is fixed with the new code.
verify you changes are well formatted by running
flake8
is installed. This command is also available on Windowsusing the Windows System for Linux once
flake8
is installed in thelocal Linux environment. While passing this test is not required, it is good practice and it help
improve code quality in
statsmodels
.