Repository navigation
ENH/BUG Bootstrap clone rebased - #5143
Conversation
|
The notebook contains the output and needs to be removed, commit "DOC add example noexog GLLM notebook" |
| background=self.pdf_b) | ||
|
|
||
| res = llh_noexog.fit() | ||
| assert np.allclose(res.params, self.params, rtol=1e-1) |
|
aside: why are df_resid, df_model nan? notebook: I prefer not to have dedented closing parenthesis. |
|
AFAICS, notebook doesn't show usage of bootstrap cov_params/bse |
|
The handling of exog=None in bootstrap looks good. It's just the minimal change without getting into the refactoring parts, see #4679 and discussion in original PR |
|
we can squash into 3 parts: |
|
df_model, df_resid are nan: there is an inconsistency between GenericLikelihoodModel and the results class model.initialize has, i.e. attribute is always set
df_resid does not affect params_table by default using use_t=False. |
| ]) | ||
| ('Df Residuals:', lambda: [num_to_str(results.df_resid)]), | ||
| # ('Df resid:', lambda: [results.df_resid]), | ||
| # ('df resid:', lambda: [results.df_resid]), #check capitalization |
There was a problem hiding this comment.
Commented out versions necessary?
There was a problem hiding this comment.
Commented out versions necessary?
There was a problem hiding this comment.
I don't know. postponed and new open issue for reviewing GenericLikelihoodModel.
this PR makes the minimal changes to fix the bug to get it to work.
| self.signal = signal | ||
| self.background = background | ||
| super(TwoPeakLLHNoExog, self).__init__(endog=endog, exog=exog, | ||
| *args, **kwargs) |
| res_bs = res.bootstrap(nrep=50) | ||
| assert res_bs is not None | ||
| smry = res.summary() | ||
| assert smry is not None |
|
I think there is a (theoretical) problem with the notebook example: but the actual Something is strange, |
Codecov Report
@@ Coverage Diff @@
## master #5143 +/- ##
==========================================
+ Coverage 81.41% 81.42% +0.01%
==========================================
Files 582 582
Lines 90331 90386 +55
Branches 10107 10110 +3
==========================================
+ Hits 73545 73600 +55
+ Misses 14488 14481 -7
- Partials 2298 2305 +7
Continue to review full report at Codecov.
|
|
I want to remove the doc notebook from this PR. My guess is that there is something wrong in the model or likelihood. The parameter estimates are fine and bootstrap works, but the hessian doesn't look correct for this problem. We cannot use an M-estimator, misspecified loglike cov_type because score_obs and/or loglike_obs is missing. As a unit test case the example is fine, but I don't want to provide as a user example in the docs, when something is not clear or appropriate in the example. (Another problem to make it clean is the support of the uniform distribution. My guess is that including the counts/nobs/n_total is to scale up the uniform pdf so the pdf of the uniform distribution is not closely tied to the support of it, i.e. uniform |
|
update: I added my current conclusion: The objective function works as M-estimator but is not a proper log-likelihood function. |
|
checking current unit test statsmodels.miscmodels.tests.test_generic_mle TestMyPareto1 which uses constraints is None my guess is that this is related to missing using TestMyParetoRestriction correction: I printed out the bootstrap results for the wrong model, i.e. for unconstrained. constrained bootstrap does have the reduced number of params |
|
bootstrap for scale parameter in MyPareto with loc restriction looks not very normal to qualify: data generating scale = 2 |
8d87738 to
19fa94e
Compare
|
I copied the notebook to https://gist.github.com/josef-pkt/892fd3a6048cf55790a66e152ba3cc7d now squashed to 3 commits.
|
|
test is missing random seed in method (class has seed but not the test method with bootstrap) |
c29f2f4 to
f68ca0b
Compare
|
All green, I'm leaving the writing of nice examples for another day. E.g. expanding on MyPareto |
| results = [] | ||
| print(self.model.__class__) | ||
| hascloneattr = True if hasattr(self, 'cloneattr') else False | ||
| hascloneattr = True if hasattr(self.model, 'cloneattr') else False |
There was a problem hiding this comment.
Is cloneattr documented somewhere?
There was a problem hiding this comment.
No, it's not advertised.
discussion in the original PR
| endog = self.endog | ||
| return self.nlnlike(params, endog) | ||
|
|
||
| def nlnlike(self, params, endog): |
There was a problem hiding this comment.
Why defining both this and nloglike?
There was a problem hiding this comment.
small advantage, nlnlike can be used with different endog
but essentially I didn't rewrite the example in the unit test.
I have a partial rewrite in my notebook, for the future.

this is a rebased version of #4676