Repository navigation
Fix conversion error in proportion_confint - #2935
Conversation
Adjusted upper and lower bounds to the optimizer when using the 'binom_test' method for proportion_confint
|
Thanks, Do you have an example for the brentq failure? First the changes are an improvement over the existing code, so are fine to merge. However, I added inversion of binom test as an "obvious method to try", but I don't remember having seen a reference for it. (AFAIU: inverting the binom_test results in exact score confidence intervals) I just checked inversion of binom test doesn't have unit tests, IIRC because it's not available in what I used as reference package. |
|
Reading through the comments and the docstring shows that I ran into this problem also. So this fix looks good and should solve that problem. Second issue in the code comments is whether the discreteness of the binomial sample space messes up the rootfinding. |
|
@BrianLondon As explanation to my comments: My comments are mostly not directly related to this PR. I wrote the function initially essentially by translating formulas into code. In the meantime, I worked on several related questions, and have a better overview over the different methods for constructing hypothesis tests and confidence intervals. All the other methods here are standard, but I need to come back to the binom_test version to check the details (definition and theory). |
| # TODO: check if we should round up or down, or interpolate | ||
| if count == 0: | ||
| ci_low = 0 | ||
| else |
|
Yeah, I would support continuing to label the method "experimental" in the docstring lacking any citations to back up the method. I can add binom inverse to the unit tests ad add a test that generates the error on the old code to avoid regressions in the future. Like I said, I don't know of any citations to validate the method, but I'm pretty sure there is a function in MATLAB that does the same thing. I can try to track it down. |
|
Yes, having at least a regression test for this would be good. Also, it would be helpful if you could find the matlab function. However, the Fay references in #2735 and related might cover this case. I didn't make the connection to this when I looked at Fay, because that was mostly related to two sample proportion tests and confint. |
|
merging as is |
|
@BrianLondon Thank you |
Adjusted upper and lower bounds to the optimizer when using the 'binom_test' method for
proportion_confintto solve thebrentq fails ValueError: f(a) and f(b) must have different signserror. Also, enforced bounds out to 0.0 or 1.0 in the case where that's the ML estimate.