Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question re: Implementation of clopper pearson in this package. #21

Open
DrLynTaylor opened this issue Nov 25, 2024 · 2 comments
Open

Comments

@DrLynTaylor
Copy link

Hi,
We were looking into why RBesT CI's for proportions using Clopper-Pearson method doesn't give an exact match to the Hmisc package. We discovered that you are using a slightly different formulae as hopefully we've described here correctly. https://psiaims.github.io/CAMIS/R/ci_for_prop.html. Is this method supported anywhere by published methods ? Could you give rationale as to why you implemented it this way?
Here is how we expalined what you've done, but please do let me know if it's incorrect. Thanks !

The {RBesT} package produces CIs using the Clopper-Pearson method. In this example (x=36 and n=154), the results match the cardx package. However, as described below, there are 2 cases where the results using RBesT package do not match cardx or Hmisc.

x = 0 (0% responders), in which case the lower limit does not match.
x = n (100% responders), in which case the upper limit does not match.
Because of the relationship between the binomial distirbution and the beta distribution. This package uses quantiles of the beta distribution to derive exact confidence intervals.

RBesT equations are:
pLow <- qbeta(Low, r + (r == 0), n - r + 1)
pHigh <- qbeta(High, r + 1, n - r + ((n - r) == 0))

If the equations were updated as follows then it would match Hmisc intervals:
pLow <- qbeta(Low, r, n - r + 1)
pHigh <- qbeta(High, r + 1, n - r)

@weberse2
Copy link
Collaborator

Thanks a lot for bringing up the matter and for going into this level of detail. Let me look into the matter.

@weberse2
Copy link
Collaborator

Again many thanks for the report here. The problem is now fixed on my local development version and a fix (as you suggest) will be included in the next release early 2025. I leave the issue open until the release is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants