Obtaining sample sizes for a given power comparing two independent proportions in R and G*POWER3
(Taken from Jeremy Miles's e-mail to psych-postgrads)
In R it's much easier and more intuitive (than using the purpose built freeware G*POWER). The command is:
power.prop.test(p1=0.2, p2=0.3, power=0.8)
And it says:
- Two-sample comparison of proportions power calculation
- n = 293.1513
- p1 = 0.2 p2 = 0.3
- sig.level = 0.05
- power = 0.8
- alternative = two.sided
- NOTE: n is number in *each* group
- Two-sample comparison of proportions power calculation
- n = 293.1513
- p1 = 0.2 p2 = 0.3
- sig.level = 0.05
- power = 0.8
- alternative = two.sided
- Two-sample comparison of proportions power calculation
Comparison doing the same calculation to that above in G*POWER 3
The above calculation can also be performed using the chi-square option in the free downloadable software G*POWER3 (or similarly and more straightforwardly using the proportions as inputs, as with R above, choosing exact tests in G*POWER3). Contingency tables are, however, fiddly to power in G*Power3 using the chi-square option. You have to put in the proportions in each of the cells for the alterative and null hypotheses by lcicking on the 'determine' button which opens up a window containing a four by two table of cells which require the inputting of probabilities representing the null and alternative hypotheses.
If, as in the example above used in R, you think your intervention will result in 30% of the participants having capacity compared to a control condition of 20% with capacity, we have the following table assuming equally sized control and intervention groups:
|
Capacity |
No Capacity |
||
Control |
0.20 |
0.80 |
||
Intervention |
0.30 |
0.70 |
whose elements we halve
|
Capacity |
No Capacity |
||
Control |
0.10 |
0.40 |
||
Psychotic Group |
0.15 |
0.35 |
since the probabilities must sum to one.
0.4, 0.1, 0.35, 0.15 go into
the second column.
Notice the row and column sums of the probabilities for the alternative hypothesis above.
|
Capacity |
No Capacity |
Row sum |
|||
Control |
0.10 |
0.40 |
0.5 |
|||
Psychotic Group |
0.15 |
0.35 |
0.5 |
|||
Column sum |
0.25 |
0.75 |
1 |
Now, under the null hypothesis, we expect the intervention not to make any difference so having the same proportion of people as in our control group with capacity, so we have
|
Capacity |
No Capacity |
Row sum |
|||
Control |
0.125 |
0.375 |
0.5 |
|||
Psychotic Group |
0.125 |
0.375 |
0.5 |
|||
Column sum |
0.25 |
0.75 |
1 |
making sure that the marginals (row and column sums) are the same as those for the alternative hypothesis above which assumed 20% of control participants had capacity and 30% (of different participants) after the intervention. The i-jth cell probability is then obtained by multiplying the respective i-th row and j-th column sums.
0.375, 0.125, 0.375, 0.125
goes into the first column.
Then you can calculate w = 0.115, and with power of 0.8, 1 degree of freedom, you need 589 individuals in total using the calculate button in G*POWER3 which agrees with the same calculation used above in R.