2

Suppose we have $10$ observations and we run $20$ trials. A two-sided binomial test with $H_0:p=0.4$ from R I get is

binom.test(x=10, n = 20, p = 0.4, alternative = c("two.sided"))
Exact binomial test

data: 10 and 20 number of successes = 10, number of trials = 20, p-value = 0.3703 alternative hypothesis: true probability of success is not equal to 0.4 95 percent confidence interval: 0.2719578 0.7280422 sample estimates: probability of success 0.5

if I assume $H_0:p=0.3$, I get

Exact binomial test

data: 10 and 20 number of successes = 10, number of trials = 20, p-value = 0.08345 alternative hypothesis: true probability of success is not equal to 0.3 95 percent confidence interval: 0.2719578 0.7280422 sample estimates: probability of success 0.5

The confidence intervals in both cases are identical. I believe that is because of a same number of observations. I found this article about the confidence intervals. But it doesn't tell me how to find k and both lower bound and upper bound.

Roger V.
  • 3,903
Simple
  • 207

1 Answers1

6

Confidence intervals are identical because number of trials, number of successes, and $\alpha$ are the same. In the linked text, it shows "a more common way to represent the Binomial Exact CI," using the relationship between the binomial CDF and the beta distribution (aka Clopper-Pearson Method). A similar formula:

$$P_{lb} = B(\alpha/2;k, n-k+1)\text{ and } P_{ub} = B(1-\alpha/2;(k+1), (n-k))$$

Where $n$ is the number of trials, $k$ number of successes, and $\alpha$ the level of significance. It is easy to implement this formula in R using qbeta:

n <- 20
k <- 10
a <- 0.05

qbeta(a/2, k, n-k+1) [1] 0.2719578 qbeta((1-a/2), k+1, n-k) [1] 0.7280422

As you can see, these are the results you get with binom.test because it also uses Clopper-Pearson interval.

T.E.G.
  • 2,332