Let’s say we need to calculate a sample size for a single proportion estimation (testing). Omitting now maths and some variability in the used formulas we can do it two in two ways:

First: using power of a single test and then we just require the test is rejecting or not the hypothesis of a given proportion to be zero (based on two-sided test usually).

Second: using the 95%CI and the desired error margin (error margin=half of the 95%CI). The problem with fixing margin is that 5% margin is something different when we estimate 50% or 70% proportion and different when we estimate 20% proportion.

First approach results:

This what we got as the result of the simulation for different values of power and effect size for the first approach.

So for example to estimate a proportion of 0.2 we need n= 263 for two sided 95%CI and power 0.9.

Note that for this method the error margin for 95%CI is not fixed (which some people are clearly not aware of). It grows with estimated proportion (see the second plot below) which is logical because we don’t need 5% margin for 70% proportion estimation (usually). For 70% we have a margin around 20% which is comparable to having 5% margin for 20% proportion more less.

So for our example with 20% proportion to estimate the first method will give us a margin error of 4.83% exactly. In other words, to estimate the minimum expected proportion of 0.2 with the margin of error 4.83% using the 95%CI we need 263 patients.

The second approach is based on fixing a margin error (third plot). As the you can see the function of the sample size in this case always has a maximum at p=0.50. So, if you want to fix a margin you can pick up the maximum n as the worst-case scenario .

The dicrepancy between these two methods comes from the fact that in the first approach 95%CI is estimated just as narrow as it is needed to reject the null hypothesis. By asking for a smaller margin in the second method you pay the price of the bigger sample size but a better estimation accuracy.

Which method to choose? It depends on your goal. If you need a smaller sample pick up method 1 but be aware of the error margin. If you need a better esitmation and can gather more individuals then the method 2 is the one to go.