{{{ DATA LIST free /alpha mdiff sd rho power. BEGIN DATA. .10 2.0 4.0 0.75 0.90 .10 2.0 4.0 0.5 0.90 END DATA. define pairt ( !pos !tokens(1) /!pos !tokens(1) /!pos !tokens(1) /!pos !tokens(1) /!pos !tokens(1)). COMPUTE #POW = !5. compute #conf = (1-!1/2). compute #lc3 = 1. compute #ind=0. compute n = 3.000. comment COMPUTE #LC1 = 10.000. COMPUTE #CUMF2 = 1 - NCDF.T(IDF.T(#conf,N+N-2),N+N-2,(!2)/SQRT((2*!3*!3/N)*(1-!4))). COMPUTE #DIFF = 1 . SET MXLOOPS=10000. LOOP IF (#DIFF GT .00005) . + DO IF (#CUMF2 LT #pow) . + COMPUTE #LC3 = N . + COMPUTE N = (N + rnd(1)). + COMPUTE #CUMF2 = 1 - NCDF.T(IDF.T(#conf,N+N-2),N+N-2,(!2)/SQRT((2*!3*!3/N)*(1-!4))). + ELSE . + COMPUTE #LC1 = n . + COMPUTE n = (n + #LC3)/2 . + COMPUTE #CUMF2 = 1 - NCDF.T(IDF.T(#conf,N+N-2),N+N-2,(!2)/SQRT((2*!3*!3/N)*(1-!4))). + END IF . + COMPUTE #DIFF = ABS(#CUMF2 - #pow) . END LOOP . 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 rho=!4. compute power=!5. formats n (f7.0) alpha (f5.2) mdiff (f5.2) sd (f5.2) rho (f5.2) power (f5.2). variable labels n 'Sample Sizes Required' /alpha 'Alpha' /mdiff 'Mean Difference' /sd 'SD' /rho 'Correlation' /power 'Power'. report format=list automatic align(center) /variables=n alpha mdiff sd rho power /title "Paired t-test sample size for given power" . !enddefine. matrix. get m /variables=alpha mdiff sd rho 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 rho=make(1,1,0). compute alpha=m(:,1). compute mdiff=m(:,2). compute sd=m(:,3). compute rho=m(:,4). compute power=m(:,5). end matrix. pairt alpha mdiff sd rho power. }}}