STAT 405 - BIOSTATISTICS

Handout 12 – Power and Sample Size for Comparing Two Proportions

This handout covers material found in Section 10.5of the text.

POWER FOR A PEARSON CHI-SQUARE TEST FOR COMPARING TWO PROPORTIONS

EXAMPLE: Otolaryngology (Example 10.28 of your text, page 418).

Suppose a study comparing a medical and a surgical treatment for children who have an excessive number of episodes of otitis media (OTM) during the first 3 years of life is planned. Success is defined as 1 or fewer episodes of OTM in the first 12 months after treatment. Success rates of 50% and 70% are assumed in the medical and surgical groups, respectively, and the recruitment of 100 patients for each group is realistically anticipated. How much power does such a study have of detecting a significant difference if α = 5% is used?

Your book provides a formula to calculate this power on page 418. We will consider the use of SAS PROC POWER in this handout:

You can use the NPERGROUP= option in a balanced design and express effects in terms of the individual proportions.
procpower;
twosamplefreq test=pchi
alpha=.05
groupproportions = (.5.7)
npergroup = 100
power = .;
run;

You can also specify sample sizes with the GROUPNS= option. This would be useful if the design were unbalanced.
procpower;
twosamplefreq test=pchi
groupproportions = (.5.7)
groupns = 100 | 100
power = .;
run;

Finally, you can alsoexpress effects in terms of relative risks.
procpower;
twosamplefreq test=pchi
relativerisk = 1.4
refproportion = 0.5
groupns = 100 | 100
power = .;
run;

POWER FOR FISHER’S EXACT TEST FOR COMPARING TWO PROPORTIONS

Let’s once again consider Example 10.28 from your text. To calculate the exact power using Fisher’s exact test, you can use the following code:

procpower;
twosamplefreq test=fisher
groupproportions = (.5.7)
npergroup = 100
power = .;
run;

Once again, note that you can use the same options as for the Pearson chi-square test power calculations. For example, note that you could have specified ‘GROUPNS = 100 | 100’.

Calculating Sample Size

How many subjects would we need in each group to achieve 90% power?

procpower;

twosamplefreq test=fisher

groupproportions = (.5.7)

npergroup = .

power = .90;

run;

POWER FOR MCNEMAR’S TEST

EXAMPLE: Cancer (Example 10.29 of your text, page 419).

Suppose we want to compare two different regimens of chemotherapy (A, B) for treatment of breast cancer, where the outcome measure is recurrence of breast cancer or death over a 5-year period. A matched-pair design is used, where patients are matched on age and clinical stage of disease. One patient in each pair is assigned to treatment A and the other to treatment B. Based on previous work, it is estimated that patients in a matched pair will respond similarly to the treatments in 85% of matched pairs. Furthermore, for matched pairs where there IS a difference in response, it is estimated that in 2/3 of the pairs the ‘A patient’ will either die or have a recurrence and the ‘B patient’ will not; in 1/3 of the pairs the ‘B patient’ will either die or have a recurrence and the ‘A patient’ will not. What is the power of the test if 600 matched pairs are used in the study?

First, we can use exact binomial probabilities. To begin, find the proportion of overall pairs that are discordant for each type:
Type A:
Type B:
procpower;
pairedfreq dist=exact_cond
discproportions = 0.05 | .1
npairs = 600
power = .;
run;

We can also use normal approximation methods to calculate the power:
procpower;
pairedfreq dist=normal
discproportions = 0.1 | 0.05
npairs = 600
power = . ;
run;

Formulae for McNemar’s Power and Sample Sizes (from text):

The sample size (# of matched pairs n) required to achieve two-tailed Power = with at the level is given below. We need specify some probabilities to use this formula which might be very difficult to estimate apriori (i.e. before collecting data). For one-sided we replace by .

projected proportion of discordant pairs of type A among discordant pairs. Type A discordant pair means A has trait but B does not.

projected proportion of discordant pairs among all pairs.

Sample size formula:

Matched pairs

Power formula:


Sample Size and Power for Comparing Two Population Proportions

(Section 10.5, pgs. 381 – 383)

If we assume that , use significance level , and want to have power when we have assumed values for , and hence , of interest then the sample sizes we need to achieve the desired power is

and

Note: if k = 1 we assume equal sample sizes.

R function:

nP1vP2 = function(a=.05,b=.10,p1,p2,k=1,onetail=F) {

q1 = 1 - p1

q2 = 1 - p2

pbar = (p1 + k*p2)/(1 + k)

qbar = 1 - pbar

za = qnorm(1-(a/2))

if (onetail) {za = qnorm(1-a)}

zb = qnorm(1-b)

d = abs(p1-p2)

n1 = (1/d^2)*(sqrt(pbar*qbar*(1+(1/k)))*za +
sqrt(p1*q1 + ((p2*q2)/k))*zb)^2

n2 = k*n1

print(paste("n1 =",ceiling(n1)," n2 =",ceiling(n2)))

}

If we plan to use sample sizes , use significance level , and we have assumed values for , and hence , of interest, then the power we achieve using a two-tail test is given by

Power =

where

,

Note: use rather than for a one-tailed alternative.

R code for the power function above is given on the next page.

powerP1P2 = function(a=0.05,p1,p2,n1,n2,onetail=F){

q1=1-p1

q2=1-p2

d=abs(p1-p2)

pbar = (n1*p1+n2*p2)/(n1+n2)

qbar=1-pbar

za = qnorm(1-(a/2))

if (onetail) {za=qnorm(1-a)}

zpow1 = d/sqrt((p1*q1/n1)+(p2*q2/n2))

zpow2 = -za*sqrt(pbar*qbar*((1/n1)+(1/n2)))/sqrt((p1*q1/n1)+(p2*q2/n2))

power=pnorm(zpow1+zpow2)

cat(paste("Power=",round(power,3)))

}

In JMP

In JMP we can use the DOE > Sample Size and Power calculator.

The options available are shown below:

Finding sample sizes ( to achieve Power = 0.90.

1