FAQ/power/pairt - CBU statistics Wiki

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment
Type the missing letters from: He's no ded, he's jus resing hs eys

Revision 1 as of 2006-08-31 10:33:35

location: FAQ / power / pairt

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.