Skip to content

BUG: update _get_init_kwds in GPP and NBP - #3888

Closed
josef-pkt wants to merge 1 commit into
statsmodels:masterfrom
josef-pkt:discrete_init_kwds
Closed

josef-pkt wants to merge 1 commit into
statsmodels:masterfrom
josef-pkt:discrete_init_kwds

Conversation

@josef-pkt

Copy link
Copy Markdown
Member

see #3887
we need to add extra kwds to _get_init_kwds

llnull needs the extra keywords for model.__init__

(I don't remember if llnull in NegativeBinomial is correct, IIRC I came across that once)

@josef-pkt josef-pkt added this to the 0.9 milestone Aug 27, 2017
@josef-pkt

josef-pkt commented Aug 27, 2017 •

Copy link
Copy Markdown
Member Author

I'm pretty sure that llnull in NegativeBinomial doesn't take the loglike_method into account, based on browsing the code.
I don't remember where I ran into this. A search doesn't find an issue or comment.

Based on the unit tests, llnull is covered for the different NegativeBinomial versions.
One likely reason: In the regression on a constant the mean prediction and implied variance are constant across observations. In that case the two models might be equivalent with the same llf and just a difference in equivalent parameterization (with different alpha).

a possible consequence and bug: If offset differs across observations, then even in a regression on a constant the mean will also differ across observations, and llnull-nb1 and llnull-nb2 should differ. (check)

@josef-pkt

Copy link
Copy Markdown
Member Author

The same, llnull independent of p, should apply to NBP and GPP. So llnull would not be incorrect and it would not be a test that we have the correct _get_init_kwds.

@josef-pkt

Copy link
Copy Markdown
Member Author

another thought: if the parameterization differs across p, then if we add start_params_null, then those will differ even if the final llf is the same.

@josef-pkt

Copy link
Copy Markdown
Member Author

Silly, most of the above is irrelevant.

We have an _init_keys attribute and _get_init_keys was only needed for the exposure transformation.
NegativeBinomial.__init__ has `self._init_keys.append('loglike_method'), so it is correct.
#1608
(I didn't search in closed issues.)

This PR is still correct because currently the internal name is different from the __init__ keyword so _init_keys cannot be used.

@josef-pkt

Copy link
Copy Markdown
Member Author

all red.
NegativeBinomialP in master has a typo in attribute name and I tested locally on top of zero-inflated branch which has the typo fix in parameterization (missing e in parametrization)
https://github.com/statsmodels/statsmodels/pull/3755/files#diff-a494553e88130577065e0b012246ca51L2739

I'm changing to the typo case and then we need to adjust it again when merging #3755.

@coveralls

coveralls commented Aug 28, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.004%) to 81.33% when pulling 4e8dfa4 on josef-pkt:discrete_init_kwds into d0af408 on statsmodels:master.

@evgenyzhurko

evgenyzhurko commented Aug 28, 2017 •

Copy link
Copy Markdown
Contributor

@josef-pkt
I can delete changes parametrization to parameterization from zero-inflated branch in statsmodels/discrete/discrete_model.py

Or you can merge this one and i'll rebase ZI branch and Truncated branch on master.

@josef-pkt

Copy link
Copy Markdown
Member Author

@evgenyzhurko I will still review the ZI PR today. Then I'll decide which way to go.
If possible I would like to merge the ZI branch, and leave the start_params issue for a follow-up. If we can merge ZI, then we would have the smallest merge conflicts and still get the parameterization typo fix into master before the release.

@josef-pkt

Copy link
Copy Markdown
Member Author

This is now included in #3908 zero-inflated PR with additional changes

@josef-pkt

Copy link
Copy Markdown
Member Author

merged as part of #3908 ec68da3

@josef-pkt josef-pkt closed this Sep 21, 2017
@josef-pkt
josef-pkt deleted the discrete_init_kwds branch September 21, 2017 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants