Diff for "FAQ/power/unpaired" - CBU statistics Wiki
location: Diff for "FAQ/power/unpaired"
Differences between revisions 10 and 11
Revision 10 as of 2006-12-07 15:43:43
Size: 2585
Editor: PeterWatson
Comment:
Revision 11 as of 2006-12-08 10:15:19
Size: 2584
Editor: PeterWatson
Comment:
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
Alpha is the (two-tailed) type I error, mdiff is the difference in group means, sd is the average group standard deviation with power inputted in the power column. The program then outputs the common group sample size. Calculations can also be done using a [attachment:unpeq.xls spreadsheet.] Alpha is the (two-tailed) type I error, mdiff is the difference in group means, sd is the average group standard deviation with power inputted in the power column. The program then outputs the common group sample size. Calculations can also be done using a [attachment:unpe.xls spreadsheet.]

[ADJUST THE EXAMPLE INPUT AS DESIRED; THEN COPY AND PASTE INTO A SPSS SYNTAX WINDOW AND RUN; OUTPUT BOTH TO SPREADSHEET AND OUTPUT WINDOW].

This program uses Cohen's d or Hedge's g as the effect size, depending on calculation of pooled group standard deviation, (see http://en.wikipedia.org/wiki/Effect_size#Cohen.27s_d) in an equal groups unpaired t-test.

Alpha is the (two-tailed) type I error, mdiff is the difference in group means, sd is the average group standard deviation with power inputted in the power column. The program then outputs the common group sample size. Calculations can also be done using a [attachment:unpe.xls spreadsheet.]

DATA LIST free
/alpha (f10.5) mdiff (f10.5) sd (f10.5) power (f10.5). 
BEGIN DATA. 
0.05 6.0 10.0 0.90
0.05 3.0 4.0 0.90
0.05 6.0 10.0 0.90
END DATA. 

define unpairt (!pos !tokens(1)
                   / !pos !tokens(1)
                   / !pos !tokens(1)
                   / !pos !tokens(1)).
COMPUTE #POW = !4.
compute #conf = (1-!1/2).
compute #lc3 = 1.
compute #ind=0.
compute n = 20.
comment COMPUTE #LC1 = 2.000.
COMPUTE #CUMF2 = 1-ncdf.t(idf.t(#conf,2*n-2),(2*n)-2,(!2)/sqrt(2*!3*!3/n)).
COMPUTE #DIFF = 10 .
SET MXLOOPS=10000.
LOOP IF (#DIFF GT .00005) .
+       DO IF (#CUMF2 LT #pow) .
+               COMPUTE #LC3 = N .
+               COMPUTE N = (N + 0.5).
+               COMPUTE #CUMF2 =  1-ncdf.t(idf.t(#conf,2*n-2),(2*n)-2,(!2)/sqrt(2*!3*!3/n)).
+       ELSE .
+               COMPUTE #LC1 = n .
+               COMPUTE n = (n - 0.5) .
+               COMPUTE #CUMF2 = 1-ncdf.t(idf.t(#conf,2*n-2),(2*n)-2,(!2)/sqrt(2*!3*!3/n)).
+       END IF .
+       COMPUTE #DIFF = ABS(#CUMF2 - #pow) .
END LOOP .
compute #pow2 = 1-ncdf.t(idf.t(#conf,2*n-2),(2*n)-2,(!2)/sqrt(2*!3*!3/n)).
compute #differ=abs(#pow-#pow2).
if (n-trunc(n) gt 0.5) #ind=1.
if (#ind eq 0) n=trunc(n)+1.
if (#ind eq 1) n=rnd(n).
EXECUTE .
compute alpha=!1.
compute mdiff=!2.
compute sd=!3.
compute power=!4.
formats n (f7.0) alpha (f5.2) mdiff (f5.2) sd (f5.2) power (f5.2).
variable labels n 'Sample Sizes Required' /alpha 'Alpha' /mdiff 'Mean Difference' /sd 'SD' /power 'Power'.
report format=list automatic align(center)
  /variables=n alpha mdiff sd power 
  /title "Unpaired t-test sample size for given power assuming equal groups" .
!enddefine.

set errors=none.

matrix.
get m /variables=alpha mdiff sd power  /missing=omit.
compute alpha=make(1,1,0).
compute mdiff=make(1,1,0).
compute sd=make(1,1,0).
compute power=make(1,1,0).
compute alpha=m(:,1).
compute mdiff=m(:,2).
compute sd=m(:,3).
compute power=m(:,4).  
end matrix.
unpairt alpha mdiff sd power.

None: FAQ/power/unpaired (last edited 2013-03-08 10:17:39 by localhost)