power oneproportion — Power analysis for a one-sample proportion test 13
where the number of successes X has a binomial distribution with the total number of trials n and a
probability of a success in a single trial p, X ∼ Bin(n, p). The power is then computed as the sum
of the above two probabilities with p = p
a
.
For example, let’s compute the power for the first row of the table. The sample size is 45, the lower
critical value is 7, and the upper critical value is 21. We use the probability functions binomial()
and binomialtail() to compute the respective lower- and upper-tailed probabilities of the binomial
distribution.
. di "Lower tail: " binomial(45,7,0.3)
Lower tail: .0208653
. di "Upper tail: " binomialtail(45,21,0.3)
Upper tail: .01352273
. di "Obs. level: " binomial(45,7,0.3) + binomialtail(45,21,0.3)
Obs. level: .03438804
. di "Power: " binomial(45,7,0.5) + binomialtail(45,21,0.5)
Power: .7242594
Each of the tails is less than 0.025 (α/2 = 0.05/2 = 0.025). The observed significance level and
power match the results from the first row of the table.
Now let’s increase the lower critical value by one, C
l
= 8, and decrease the upper critical value
by one, C
u
= 20:
. di "Lower tail: " binomial(45,8,0.3)
Lower tail: .04711667
. di "Upper tail: " binomialtail(45,20,0.3)
Upper tail: .02834511
Each of the tail probabilities now exceeds 0.025. If we could use values between 7 and 8 and between
20 and 21, we could match the tails exactly to 0.025, and then the monotonicity of the power function
would be preserved. This is impossible for the binomial distribution (or any discrete distribution)
because the number of successes must be integers.
Because of the saw-toothed nature of the power curve, obtaining an optimal sample size becomes
tricky. If we wish to have power of 80%, then from the above table and graph, we see that potential
sample sizes are 47, 49, 52, 54, and so on. One may be tempted to choose the smallest sample
size for which the power is at least 80%. This, however, would not guarantee that the power is at
least 80% for any larger sample size. Instead, Chernick and Liu (2002) suggest selecting the smallest
sample size after which the troughs of the power curve do not go below the desired power. Following
this recommendation in our example, we would pick a sample size of 54, which corresponds to the
observed significance level of 0.037 and power of 0.83.
In the above, we showed the power curve for the sample sizes between 45 and 60. It may be a
good idea to also look at the power plot for larger sample sizes to verify that the power continues to
increase and does not drop below the desired power level.
Computing effect size and target proportion
In an analysis of a one-sample proportion, the effect size δ is often defined as the difference
between the alternative proportion and the null proportion, δ = p
a
− p
0
.
Sometimes, we may be interested in determining the smallest effect and the corresponding alternative
or target proportion that yield a statistically significant result for prespecified sample size and power.
In this case, power, sample size, and null proportion must be specified. In addition, you must also