# Calculate precision with constant sample size

Could somebody please help me to understend the following table? Is this a precision estimate for a given sample size?

My colleage said that for this study, there is no formal sample size calculation, and the number of samples is based on the availability in the data bases. (Sample size is going to be ~100). The following power consideration is based on the precision ( = width of the 95% confidence interval) to estimate the proportion of matched therapies.

Proportion  Precision ( = width of the 95% confidence interval)
10% or 90%  5.5%
20% or 80%  7.2%
40% or 60%  8.8%
50% 8.9%


This is a table for a sample of either $$n=500$$ or $$501$$ subjects, not $$100.$$

Perhaps the best confidence interval method for binomial data of this kind (where each observation is independent of the others and all are modeled as random binary outcomes with a common probability) is the Clopper-Pearson interval. Given a sample size $$n$$ and an observed proportion $$p$$ of one given outcome, the 95% confidence interval is a range of proportions. If you use the Clopper-Pearson procedure many times, in the long run the range it reports will include the true (but unknown) proportion 95% of the time.

For a given $$n,$$ such as $$n=100$$ in the question, we may tabulate the lower and upper limits of the 95% confidence interval as a function of the proportion of subjects exhibiting a given outcome. Here are the Clopper-Pearson intervals for some of these proportions. All values are in percent.

### $$n=100$$

       10%  20%  40%  50%  60%  80%  90%
Lower  4.9 12.7 30.3 39.8 49.7 70.8 82.4
Upper 17.6 29.2 50.3 60.2 69.7 87.3 95.1
Width 12.7 16.5 19.9 20.3 19.9 16.5 12.7


### $$n=500$$

       10%  20%  40%  50%  60%  80%  90%
Lower  7.5 16.6 35.7 45.5 55.6 76.2 87.0
Upper 13.0 23.8 44.4 54.5 64.3 83.4 92.5
Width  5.5  7.2  8.8  8.9  8.8  7.2  5.5


The "Width" values are the differences between the upper and lower limits of these intervals (rounded to 0.1%, of course). The second one, for $$500$$ subjects, reproduces the table in the question. The table for $$501$$ subjects is the same. Tables for all other sample sizes have different sets of widths than shown in the question.

Evidently you should perform this calculation for whatever values of $$n$$ you are contemplating. I did it using the exactci function in the PropCIs package for R. Below is the code if you would like to use it: just change the value of n at the outset.

You can avoid such calculations by using an accurate approximation: for $$p$$ and $$n$$ in this range ($$n$$ in the hundreds or more and $$p$$ between $$10\%$$ and $$90\%$$), the width is inversely proportional to the square root of $$n.$$ For example, knowing that with proportion 20% and $$n=100$$ the width is $$16.5\%,$$ for the same proportion and $$n=200$$ the width should be close to $$16.5\% \times \sqrt{100/200} = 11.7\%,$$ very close to the Clopper-Pearson width of $$11.5\%.$$

library(PropCIs)
n <- 100
p <- c(10,20,40,50, 60, 80, 90)/100
CI <- function(p) {
x <- exactci(p*n, n, 0.95)\$conf.int
c(x, diff(x))
}
X <- sapply(p, CI)
colnames(X) <- paste0(100*p, "%")
rownames(X) <- c("Lower", "Upper", "Width")
round(100*X, 1)

• Thank you very much for this very detailed, comprehensive answer. – Zipfer Jan 31 '20 at 10:35