Skip to content

ENH: add NegativeBinomial-P rebased - #3874

Merged
josef-pkt merged 10 commits into
statsmodels:masterfrom
josef-pkt:nb-p_rebased
Aug 21, 2017
Merged

josef-pkt merged 10 commits into
statsmodels:masterfrom
josef-pkt:nb-p_rebased

Conversation

@josef-pkt

Copy link
Copy Markdown
Member

this is currently just a rebase of #3832

@coveralls

coveralls commented Aug 18, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.07%) to 81.323% when pulling a8762d2 on josef-pkt:nb-p_rebased into 6625458 on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member Author

This pull request introduces 3 alerts - view on lgtm.com

new alerts:

  • 2 for Module-level cyclic import
  • 1 for First argument to super() is not enclosing class

Comment posted by lgtm.com

@josef-pkt

Copy link
Copy Markdown
Member Author

doc build on travis fails, but it also failed in master after adding just a csv file and no changes to code https://travis-ci.org/statsmodels/statsmodels/builds/265820201

@josef-pkt josef-pkt left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more docstring changes

rest maybe in follow-up with margins unit test

def fit_regularized(self, start_params=None, method='l1',
maxiter='defined_by_method', full_output=1, disp=1, callback=None,
alpha=0, trim_mode='auto', auto_trim_tol=0.01, size_trim_tol=1e-4,
qc_tol=0.03, **kwargs):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should get a generic docstring

Comment thread statsmodels/discrete/discrete_model.py Outdated
def score(self, params):
"""
Generalized Negative Binomial (NB-P) model score (gradient)
vector of the log-likelihood

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

summary line should be one line

Comment thread statsmodels/discrete/discrete_model.py Outdated

for i in range(dim):
for j in range(i, -1, -1):
hess_arr[i, j] = np.sum(self.exog[:, i] * self.exog[:, j] * coeff)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can avoid loop for this

Comment thread statsmodels/discrete/discrete_model.py Outdated
((1 + a4) * (1 - a3 / a2) / a2 -
p * (np.log(a1 / a2) - digamma(a1) + digamma(a3) + 2) / mu +
p * (a3 / mu + a4) / a2 +
a4 * (polygamma(1, a1) - polygamma(1, a3))) / alpha).sum()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this loop can also be vectorized

Comment thread statsmodels/discrete/discrete_model.py Outdated
def fit(self, start_params=None, method='bfgs', maxiter=35,
full_output=1, disp=1, callback=None, use_transparams = False,
cov_type='nonrobust', cov_kwds=None, use_t=None, **kwargs):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring missing, generic ?

@josef-pkt

Copy link
Copy Markdown
Member Author

@evgenyzhurko I just pushed an update including the cherry-pick of your last commit.

One substantial change is in the default p, I am switching to p=2 as default to have the same default in NegativeBinomial and NegativeBinomialP (i.e. nb2). Given that you used explicit p in the unit tests, those will not change.

I added the margins test corresponding to NB2, and they pass without changes for p=2.

I will merge when it is green, so you can reuse it in other branches after rebasing on master, but there are a few doc and style changes left for a follow-up.

@coveralls

coveralls commented Aug 21, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.07%) to 81.326% when pulling 46d4e75 on josef-pkt:nb-p_rebased into 6625458 on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member Author

This pull request introduces 3 alerts - view on lgtm.com

new alerts:

  • 2 for Module-level cyclic import
  • 1 for First argument to super() is not enclosing class

Comment posted by lgtm.com

@josef-pkt

Copy link
Copy Markdown
Member Author

green (except for ARIMA appveyor failure)

merging

@josef-pkt
josef-pkt merged commit 92a66d7 into statsmodels:master Aug 21, 2017
@josef-pkt josef-pkt added this to the 0.9 milestone Oct 22, 2017
@josef-pkt josef-pkt mentioned this pull request Apr 9, 2018
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