R

The prop_power() function from the catfun package can be used for conducting power analyses for comparisons of two proportions in R.

Computing power for fixed sample size

The prop_power() function can be used to calculate power for equal group sample sizes.

prop_power(n = 220, p1 = 0.35, p2 = 0.2, alpha = 0.05)
## 
##   Two-sample comparison of proportions power calculation 
## ---------------------------------------------------------------------
## 
## Total sample size: 220 
## N1: 110 
## N2: 110 
## Proportion 1: 0.35 
## Proportion 2: 0.2 
## Power: 0.705077 
## Significance level: 0.05

Computing sample size given power (balanced)

The prop_power() function can also be used to calculate sample size given power. Instead of specifying the number of observations per group or the total sample size, we specify the desired power.

prop_power(p1 = 0.35, p2 = 0.2, power = 0.80, alpha = 0.05)
## 
##   Two-sample comparison of proportions power calculation 
## ---------------------------------------------------------------------
## 
## Total sample size: 275.8295 
## N1: 137.9148 
## N2: 137.9148 
## Proportion 1: 0.35 
## Proportion 2: 0.2 
## Power: 0.8 
## Significance level: 0.05

Computing sample size given power (unbalanced)

The prop_power() function can be used to calculate unbalanced sample sizes. The fraction argument is set to 2/3 indicating that 2/3 of the total sample will be members of group one.

prop_power(p1 = 0.35, p2 = 0.2, fraction = 2/3, alpha = 0.05, power = 0.85)
## 
##   Two-sample comparison of proportions power calculation 
## ---------------------------------------------------------------------
## 
## Total sample size: 359.6202 
## N1: 239.7468 
## N2: 119.8734 
## Proportion 1: 0.35 
## Proportion 2: 0.2 
## Power: 0.85 
## Significance level: 0.05

SAS

Power analyses in SAS are conducting using the power procedure.

Computing power for fixed sample size

title1 'Computing Power Given Sample Size';
proc power; 
  twosamplefreq test = pchi
  alpha = 0.05
  groupproportions = (0.35 0.20)
  nullproportiondiff = 0
  groupweights = (1 1)
  ntotal = 220
  power = .;
run;
##                                    Computing Power Given Sample Size
## 
##                                           The POWER Procedure
##                            Pearson Chi-square Test for Proportion Difference
## 
##                                         Fixed Scenario Elements
## 
##                            Distribution                     Asymptotic normal
##                            Method                        Normal approximation
##                            Null Proportion Difference                       0
##                            Alpha                                         0.05
##                            Group 1 Proportion                            0.35
##                            Group 2 Proportion                             0.2
##                            Group 1 Weight                                   1
##                            Group 2 Weight                                   1
##                            Total Sample Size                              220
##                            Number of Sides                                  2
## 
## 
##                                              Computed Power
##  
##                                                  Power
## 
##                                                  0.705

Computing sample size given power (balanced)

title1 'Computing Sample Size Given Power';
proc power; 
  twosamplefreq test = pchi
  alpha = 0.05
  groupproportions = (0.35 0.20)
  nullproportiondiff = 0
  npergroup = .
  power = 0.80;
run;
##                                    Computing Sample Size Given Power
## 
##                                           The POWER Procedure
##                            Pearson Chi-square Test for Proportion Difference
## 
##                                         Fixed Scenario Elements
## 
##                            Distribution                     Asymptotic normal
##                            Method                        Normal approximation
##                            Null Proportion Difference                       0
##                            Alpha                                         0.05
##                            Group 1 Proportion                            0.35
##                            Group 2 Proportion                             0.2
##                            Nominal Power                                  0.8
##                            Number of Sides                                  2
## 
## 
##                                           Computed N per Group
##  
##                                             Actual    N per
##                                              Power    Group
## 
##                                              0.800      138

Computing sample size given power (unbalanced)

title1 'Computing Sample Size Given Power (Unbalanced Groups)';
proc power; 
  twosamplefreq test = pchi
  alpha = 0.05
  groupproportions = (0.35 0.20)
  nullproportiondiff = 0
  groupweights = (2 1)
  ntotal = .
  power = 0.85;
run;
##                          Computing Sample Size Given Power (Unbalanced Groups)
## 
##                                           The POWER Procedure
##                            Pearson Chi-square Test for Proportion Difference
## 
##                                         Fixed Scenario Elements
## 
##                            Distribution                     Asymptotic normal
##                            Method                        Normal approximation
##                            Null Proportion Difference                       0
##                            Alpha                                         0.05
##                            Group 1 Proportion                            0.35
##                            Group 2 Proportion                             0.2
##                            Group 1 Weight                                   2
##                            Group 2 Weight                                   1
##                            Nominal Power                                 0.85
##                            Number of Sides                                  2
## 
## 
##                                             Computed N Total
##  
##                                             Actual        N
##                                              Power    Total
## 
##                                              0.850      360