Repository navigation
Conversation
|
@kshedden another quick implementation, now that I figured out how to do these things. profile loglikelihood confidence intervals based on restricting a parameter through offset. I haven't looked at R, and I think Stata doesn't have it. |
|
I found this R package, but I haven't tried it: On Thu, Jun 26, 2014 at 11:41 AM, Josef Perktold [email protected]
|
|
Needs a rebase. |
|
needs more unit tests and better start_params, based on comment in code for start_params: do I have a function for one-step constraint estimation from unconstrained estimate? |
|
about one-step estimate of constrained params, see #3676 (comment) formula in Stata documentation. |
10aeb20 to
8a97470
Compare
|
rebased (minor merge conflict) |
|
Note: we can add consistency cross-checks in unit tests against compare_lr_test (when we have them) |
| offset_model = 0 | ||
|
|
||
|
|
||
| def llf_p(p1, idx, return_res=False): |
There was a problem hiding this comment.
outsource this so we can get the full profile likelihood function as Kerby wanted
| from scipy import optimize | ||
|
|
||
|
|
||
| def conf_int_profile(results, index=None, alpha=0.05): |
There was a problem hiding this comment.
add optional _llf=None for cross checking
|
Another idea as safeguard Weakening the requirements: I think we only need deviance in the GLM case. That would avoid computing the, currently missing, loglike in Tweedie. |
|
bump to 0.10 |
8a97470 to
eeaed7d
Compare
|
rebased, no merge conflicts |
Codecov Report
@@ Coverage Diff @@
## master #1791 +/- ##
==========================================
+ Coverage 79.32% 79.33% +0.01%
==========================================
Files 544 545 +1
Lines 81718 81771 +53
Branches 9255 9261 +6
==========================================
+ Hits 64822 64873 +51
Misses 14802 14802
- Partials 2094 2096 +2
Continue to review full report at Codecov.
|
eeaed7d to
6ec9f26
Compare
|
rebased again, no merge conflict |
|
travis 2.7 has early stopping as in #4716 |
|
There might be an issue here with fixing the scale, if we don't use MLE for scale. Maybe we should keep scale fixed at MLE during computation of profile likelihood, unless we consider it as full MLE (with scale estimated by pearson chi2 as approximation). For dispersion QMLE, e.g. quasi-poisson, we might want to fix excess dispersion scale. I don't remember whether excess dispersion scale is correctly included in log like. It should be since thequackdaddy fixed it. |
|
for unit tests against R: R seems to switch automatically between wald and profile likelihood confint depending on whether MASS is loaded. (I guess I had MASS already in my workspace, example for R docs or somewhere (I did this a week ago) |
|
as an aside: |
|
The function is in a new, specific module. optimization needs checking for robustness, convergence problems. we might need scale options. in GLM Also needs checking for reusability with other models, e.g. Poisson model requires offset |
|
Converting this to a class would allow us to reuse code to compute the likelihood profile (concentrated likelihood as function of params_i)
converting to class and doing |
|
code sharing with #2722 score confidence intervals Recreating the model and estimation of offset mode will be common to both. |
|
statsmodels/stats/profile_likelihood.py is not a good location for helper/results function base has now |
This creates profile confidence intervals for individual (single) parameters using offset to fix a parameter.
Example GLM binomial
test case: compares with regular conf_int, only tried for GLM binomial case
see test case for example