|
Size: 1540
Comment:
|
Size: 2407
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| This program uses the difference in proportions (or equivalently the odds ratio) as the effect size, see [http://en.wikipedia.org/wiki/Effect_size#Cohen.27s_d. here]. | |
| Line 2: | Line 3: |
| The effect size used here is the Odds Ratio See http://en.wikipedia.org/wiki/Effect_size#Cohen.27s_d which can also be expressed as a difference in proportions. |
p1 and p2 are the proportions in groups 1 and 2 being compared, delta is the ratio group 2 size/group 1 size, n1 is the sample size of group 1 and alpha is the (two-tailed) type I error. The program then outputs the power. Power may also be computed using a [attachment:bin2.xls spreadsheet] or [:FAQ/powppR:in R.] |
| Line 5: | Line 5: |
| [ADJUST THE EXAMPLE INPUT AS DESIRED; THEN COPY AND PASTE INTO A SPSS SYNTAX WINDOW AND RUN; OUTPUT BOTH TO SPREADSHEET AND OUTPUT WINDOW]. |
|
| Line 7: | Line 9: |
| /p1 p2 ratio ntot alpha. BEGIN DATA. 0.19 0.09 1 311 0.05 0.19 0.09 4 311 0.05 0.19 0.09 3 600 0.05 END DATA. compute p11= (p1*ratio)/(1+ratio). compute p12=((1-p1)*ratio)/(1+ratio). compute p21=p2/(1+ratio). compute p22=(1-p2)/(1+ratio). compute oddsr = (p11*p22)/(p21*p12). exe. |
/alpha p1 p2 delta n1. BEGIN DATA. .05 0.19 0.09 1 167 .05 0.39 0.25 1 100 END DATA. |
| Line 23: | Line 16: |
| get m /variables=p11 p12 p21 p22 ntot alpha /missing=omit. compute p11=make(1,1,0). compute p12=make(1,1,0). compute p21=make(1,1,0). compute p22=make(1,1,0). |
get m /variables=alpha p1 p2 delta n1 /missing=omit. |
| Line 29: | Line 18: |
| compute p11=m(:,1). compute p12=m(:,2). compute p21=m(:,3). compute p22=m(:,4). compute ntot=m(:,5). compute alpha=m(:,6). |
compute p1=make(1,1,0). compute p2=make(1,1,0). compute delta=make(1,1,0). compute n1=make(1,1,0). compute alpha=m(:,1). compute p1=m(:,2). compute p2=m(:,3). compute delta=m(:,4). compute n1=m(:,5). |
| Line 36: | Line 28: |
| COMPUTE #chisq1 = (LN(oddsr)/(sqrt((1/p11)+(1/p12)+(1/p21)+(1/p22))))**2. compute #df=1. compute #conf = 1-alpha. compute #chisq=ntot*#chisq1. compute power = 1 - NCDF.CHISQ(IDF.CHISQ(#conf,#DF),#DF,#CHISQ). compute p1=p11/(p11+p12). compute p2=p21/(p21+p22). compute ratio = (p11+p12)/(p21+p22). formats p1 (f5.2) p2 (f5.2) alpha (f5.2) ntot (f5.2) power (f5.2). variable labels p1 'Proportion 1' /p2 'Proportion 2' /ratio 'Ratio group 1 to group 2' /alpha 'Two-Tailed Alpha' /ntot 'Sample Size' /power 'Power'. |
compute n2=delta*n1. compute #pbar= (n1*p1 + n2*p2) / (n1+n2). compute #z2= ( (p1-p2) /sqrt( #pbar*(1-#pbar)*( (1/n1) + (1/n2) ) ) )**2. compute oddsr = ( n1*p1*n2*(1-p2) ) / ( n1*(1-p1)*n2*p2 ). compute power=1-ncdf.chisq(idf.chisq(1-alpha,1),1,#z2). exe. formats n1 (f7.0) n2 (f7.0) alpha (f5.2) p1 (f5.2) p2 (f5.2) power (f5.2). variable labels n1 'Sample Size 1' /n2 'Sample Size 2' /alpha 'Alpha' /p1 'Proportion 1' /p2 'Proportion 2' /oddsr 'Odds Ratio' /power 'Power'. |
| Line 47: | Line 37: |
| /variables=p1 p2 ratio alpha ntot power /title "Power for given sample size for an Odds Ratio from a 2x2 table of proportions" . |
/variables=n1 n2 alpha p1 p2 oddsr power /title "Power for Independent proportions given sample sizes" . exe. compute #contc= 0.5*((1/n1)+(1/n2)). compute #pbar= (n1*p1 + n2*p2) / (n1+n2). compute #z21= ( ( abs(p1-p2)-#contc ) /sqrt( #pbar*(1-#pbar)*( (1/n1) + (1/n2) ) ) )**2. compute oddsr = ( n1*p1*n2*(1-p2) ) / ( n1*(1-p1)*n2*p2 ). compute power=1-ncdf.chisq(idf.chisq(1-alpha,1),1,#z21). formats n1 (f7.0) n2 (f7.0) alpha (f5.2) p1 (f5.2) p2 (f5.2) power (f5.2). variable labels n1 'Sample Size 1' /n2 'Sample Size 2' /alpha 'Alpha' /p1 'Proportion 1' /p2 'Proportion 2' /oddsr 'Odds Ratio' /power 'Power'. report format=list automatic align(center) /variables=n1 n2 alpha p1 p2 oddsr power /title "Power for Independent proportions given sample sizes (continuity correction)" . |
This program uses the difference in proportions (or equivalently the odds ratio) as the effect size, see [http://en.wikipedia.org/wiki/Effect_size#Cohen.27s_d. here].
p1 and p2 are the proportions in groups 1 and 2 being compared, delta is the ratio group 2 size/group 1 size, n1 is the sample size of group 1 and alpha is the (two-tailed) type I error. The program then outputs the power. Power may also be computed using a [attachment:bin2.xls spreadsheet] or [:FAQ/powppR:in R.]
[ADJUST THE EXAMPLE INPUT AS DESIRED; THEN COPY AND PASTE INTO A SPSS SYNTAX WINDOW AND RUN; OUTPUT BOTH TO SPREADSHEET AND OUTPUT WINDOW].
DATA LIST free /alpha p1 p2 delta n1. BEGIN DATA. .05 0.19 0.09 1 167 .05 0.39 0.25 1 100 END DATA. matrix. get m /variables=alpha p1 p2 delta n1 /missing=omit. compute alpha=make(1,1,0). compute p1=make(1,1,0). compute p2=make(1,1,0). compute delta=make(1,1,0). compute n1=make(1,1,0). compute alpha=m(:,1). compute p1=m(:,2). compute p2=m(:,3). compute delta=m(:,4). compute n1=m(:,5). end matrix. compute n2=delta*n1. compute #pbar= (n1*p1 + n2*p2) / (n1+n2). compute #z2= ( (p1-p2) /sqrt( #pbar*(1-#pbar)*( (1/n1) + (1/n2) ) ) )**2. compute oddsr = ( n1*p1*n2*(1-p2) ) / ( n1*(1-p1)*n2*p2 ). compute power=1-ncdf.chisq(idf.chisq(1-alpha,1),1,#z2). exe. formats n1 (f7.0) n2 (f7.0) alpha (f5.2) p1 (f5.2) p2 (f5.2) power (f5.2). variable labels n1 'Sample Size 1' /n2 'Sample Size 2' /alpha 'Alpha' /p1 'Proportion 1' /p2 'Proportion 2' /oddsr 'Odds Ratio' /power 'Power'. report format=list automatic align(center) /variables=n1 n2 alpha p1 p2 oddsr power /title "Power for Independent proportions given sample sizes" . exe. compute #contc= 0.5*((1/n1)+(1/n2)). compute #pbar= (n1*p1 + n2*p2) / (n1+n2). compute #z21= ( ( abs(p1-p2)-#contc ) /sqrt( #pbar*(1-#pbar)*( (1/n1) + (1/n2) ) ) )**2. compute oddsr = ( n1*p1*n2*(1-p2) ) / ( n1*(1-p1)*n2*p2 ). compute power=1-ncdf.chisq(idf.chisq(1-alpha,1),1,#z21). formats n1 (f7.0) n2 (f7.0) alpha (f5.2) p1 (f5.2) p2 (f5.2) power (f5.2). variable labels n1 'Sample Size 1' /n2 'Sample Size 2' /alpha 'Alpha' /p1 'Proportion 1' /p2 'Proportion 2' /oddsr 'Odds Ratio' /power 'Power'. report format=list automatic align(center) /variables=n1 n2 alpha p1 p2 oddsr power /title "Power for Independent proportions given sample sizes (continuity correction)" .
