# Inverting a test to find lower confidence interval

I'm trying to come up with how to invert a hypothesis test to obtain a lower confidence bound, specifically for a binomial distribution. So suppose you have a binomial distribution with 5 trials, and 4 successes, and you want to obtain a lower confidence interval, of say 95%.

Typically the way I've previously learned would be to just use the normal approximation, and find the critical value. However, to do this we typically require that $$n\hat{p}\geq5$$ and $$n(1-\hat{p})\geq 5$$, so for the observed proportion of $$4/5$$, we cannot proceed in this manner.

So how should one go about inverting a hypothesis test here?

You are correct that a normal approximation would not be reliable for the specific outcome you mention.

Something like this may have been implemented in the binom.test procedure in R. [If a hypothetical value is not entered, then $$p_0 = 0.5$$ is assumed.]

First, get the CI corresponding to 4 successes in 5 trials:

binom.test(4, 5, alt="g")

Exact binomial test

data:  4 and 5
number of successes = 4, number of trials = 5,
p-value = 0.1875
alternative hypothesis:
true probability of success is greater than 0.5
95 percent confidence interval:
0.3425917 1.0000000
sample estimates:
probability of success
0.8

Then verify that using the bound of the CI to specify the null hypothesis, puts you at the edge of the non-rejection region.

binom.test(4, 5, p=.3426, alt="g")

Exact binomial test

data:  4 and 5
number of successes = 4, number of trials = 5,
p-value = 0.05

alternative hypothesis:
true probability of success is greater than
0.3426
95 percent confidence interval:
0.3425917 1.0000000
sample estimates:
probability of success
0.8

Because of the discreteness of the binomial distribution and the particulars of the style of CI implemented, you need to be careful about definitions. Please read the documentation of binom.test to see if it really does what you have in mind. Especially:

Details

Confidence intervals are obtained by a
procedure first given in Clopper and Pearson
(1934). This guarantees that the confidence
level is at least 'conf.level', but in general
does not give the shortest-length confidence
intervals.

Also, the Wikipedia page on CIs for binomial proportions may be useful--especially, the section on Clopper-Pearson CIs.