4

I have a simulation (a set of 200 iterations) which I used to compute a confidence interval for average statistical power. In binomial approximation, I know that the standard error is computed as $\sqrt{\frac{p(1-p)}{n}}$ where $p$ is the success probability and $n$ is the sample size. As I mentioned before, my $n=200$ as 200 iterations. Assume that in some instance I got statistical power exactly equal to 1 (when averaged from 200 iterations) and it is clear that the standard error is equal to 0 (computed as $\sqrt{\frac{p(1-p)}{n}} = \sqrt{\frac{1(1-1)}{200}} = 0$), and hence the confidence interval is no longer an interval, but a point (which is 1). If I need to get a confidence interval where there is no overlap in lower limit and upper limit,

  1. can I use continuity correction (if this is not called so, what is it)?
  2. if yes, what will be the computational formula?
  3. reference(s)?

I could not find a proper reference which is applicable for my case (when sample size is 200 range – in case if there's any such constraint of sample size).

ETA: As a community suggestion, I was given reference to a similar question posted earlier Confidence interval around binomial estimate of 0 or 1, but I do not see it is helpful since the sample size is too small (typically less than 100 cannot be approximated normal). My case n=200, so I am not sure how to relate that response to my question. Plus I would appreciate references of a valid well-established method, and therefore, the quoted link will not provide answers to my question, though it looks similar.

feetwet
  • 1,108
  • @HarveyMotulsky Thanks for the link. I do not see it is helpful since the sample size is too small (typically less than 100 cannot be approximated normal). My case n=200, so I am not pretty sure how to relate that response to my question. Plus I would appreciate references of a valid well-established method. – Dovini Jayasinghe Dec 13 '23 at 04:34
  • 3
    The point is that the normal approximation is bad, in particular at the parameter boundary, regardless of sample size. Both the linked question and the answer(s) below give alternative methods that don't suffer from this problem, namely the normal distribution not respecting the hard [0, 1] bounds. Something that performs well for small samples will usually also do well for larger ones (computational difficulties aside), it's the opposite that is much less true. – PBulls Dec 13 '23 at 09:49
  • 3
    The "rule of three", giving intervals of $[0,\frac{3}{n}]$ or $[1-\frac{3}{n},1]$, is quick and easy for a $95%$ confidence interval and can easily be adjusted for other confidence levels. – Henry Dec 13 '23 at 14:11
  • @Henry Thank you for the alternative. Could you kindly share the correct reference of "the rule of three" to be able to cite in my article? – Dovini Jayasinghe Dec 13 '23 at 22:25
  • Wikipedia has references or something like https://www.jstor.org/stable/2685405 but the argument is simple: at the lower end, if the probability of success is $p$ then the probability of no successes out of $n$ attempts is $(1-p)^n$ and this is greater than $0.95$ when $p < 1-(1-0.95)^{1/n}$, for which $p <\frac{-\log_e(0.05)}n \approx \frac3n$ is a conservative approximation. The upper end just subtracts this result from $1$ for $n$ successes out of $n$ attempts – Henry Dec 13 '23 at 23:21
  • Thanks, Henry. Will check that out. – Dovini Jayasinghe Dec 14 '23 at 00:07

2 Answers2

11

Confidence intervals for a binomial probability parameter can be formed using the Wilson score interval and this interval respects the allowable parameter range for the probability parameter. It also accommodates the extreme case where all observations are in one of the binary categories. This case is discussed in O'Neill (2021) (p. 5), which also outlines some other properties of these intervals. When we have $n$ data points with sample mean $\bar{x}=1$ and the confidence interval with confidence level $1-\alpha$ is given by:

$$\text{CI}(1-\alpha) = \bigg[ \frac{n}{n+\chi_\alpha^2}, 1 \bigg],$$

where $\chi_\alpha^2$ is the critical point corresponding to an upper tail area of $\alpha$ for the chi-squared distribution with one degree-of-freedom. For example, with $n=200$ data points that are all ones and using a 95% confidence level (giving $\chi_\alpha^2 = 3.841459$) you get the confidence interval:

$$\text{CI}(0.95) = \bigg[ \frac{200}{203.841459}, 1 \bigg] = [0.9811547, 1].$$

Ben
  • 124,856
  • Many thanks, Ben. This is perfect! – Dovini Jayasinghe Dec 13 '23 at 04:53
  • 4
    Does it make sense to merge this excellent answer into Confidence interval around binomial estimate of 0 or 1 and to dupe-close this thread as the other one? – Stephan Kolassa Dec 13 '23 at 11:07
  • @StephanKolassa, this seems to be a good idea to merge the whole post to the linked one so that Ben's answer can be found in a single place. – User1865345 Dec 13 '23 at 15:59
  • OK, I flagged this answer for mod attention and requested the merge. – Stephan Kolassa Dec 13 '23 at 16:10
  • 2
    @StephanKolassa That's a good idea, but we have to be extremely cautious about merging, for two reasons. First, we cannot move selected posts: the entire thread (minus the original question) moves to the destination. Second, merging is irreversible. Since some posts in the present thread directly address the present question but not the duplicate question, I have some concerns about this operation. An alternative (not a great one, I admit, but it's practicable) is to drop a comment (or even edit) in the duplicate referencing specific answers here. – whuber Dec 13 '23 at 17:18
  • 3
    A simpler alternative would be for Ben to just cross-post this answer to the duplicate thread, with a link back here. – Stephan Kolassa Dec 13 '23 at 17:20
  • 2
    @StephanKolassa: Good suggestion. I've posted another version of this answer (slightly more elaborated) at the linked question. I've not linked back here because it is not clear to me that the other question/answer benefits from link back to this one. – Ben Dec 13 '23 at 21:27
7

I'd like to point out two misunderstandings I suspect in the question:


As a community suggestion, I was given reference to a similar question posted earlier Confidence interval around binomial estimate of 0 or 1, but I do not see it is helpful since the sample size is too small (typically less than 100 cannot be approximated normal). My case n=200, so I am not pretty sure how to relate that response to my question.

The typical recommendation about when it is OK to use the normal approximation for binomial proportion confidence intervals is that $np$ and $n(1-p)$ need to be $\geq 5$. So the absolute sample size alone is not sufficient: whatever the sample size is, $p$ can be too close to 0 or 1 to allow this approximation. And that is what happens in your case. The linked question is thus relevant pretty much regardless of what $n$ is. I'll thus also vote to close this question as duplicate.


Secondly I suspect that the underlying source of confusion may be the following:

As you (indirectly) say, the variance of a binomial distribution is $s^2 (k) = np(1-p)$, i.e. the variance in the number of observed "successes" $k$ for a binomial distribution that truly has probability $p$ after $n$ trials. Thus, the variance in the observed proportion $\hat p = \frac{k}{n}$ is $s^2 (\hat p) = \frac{p(1-p)}{n}$.

Now, it is crucial to realize that this variance is still formulated as a function of the true probability $p$, not the observed proportion $\hat p$. And for that it is correct: the observed proportion must have variance 0 given that the true probability is 0 or 1.
However, for the confidence interval, you'd rather need the variance given the observed proportion.

To put it slightly differently, for $\hat p = 0$ (or 1), the plug-in approximation of $p \approx \hat p$ does not work well: it disregards the obvious and important possibility that other true $p$ than 0 (or 1) can lead to 0 observed successes (failures).
For example, with $n = 200$ an true probability of $p = 0.99$ has a 13 % chance of yielding $k = 200$ and thus an observed probability of $\hat p = 1$.

If you follow through with this thought and apply Bayes theorem, i.e., you calculate the $Pr(\hat p|p, n)$ for all possible $p$ and then normalize* this to get the distribution of $Pr (p | \hat p, n)$ you can derive intervals as provided e.g. R package binom does in binom.bayes().

* and weight: if you do not weight but consider all $p \in [0, 1]$ equally likely before that binomial trial, that corresponds to a uniform prior. Others choose to use Jeffrey's prior (which does not differ much for $n = 200$ - you may say, the two priors differ by half a trial with half a success). That's the interval called "Jeffrey's" in the Brown paper in the linked question's answer.