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 odd characters out in each group: abz2a 125t7 HhHaHh year.s 5433r21 worl3d

location: FAQ / power / pairt

This program uses Cohen's d as the effect size as recommended by Dunlop, W. P., Cortina, J. M., Vaslow, J. B., & Burke, M. J. (1996) for a paired t-test. This is the same as Cohen's d for a unpaired t-test when the correlation between groups, rho, is zero.

Alpha is the (two-tailed) type I error, mdiff is the difference in group means, sd is the average group standard deviation with (common group) power, power, and the correlation between groups equal to rho. The program then outputs the sample size required per group. Computations can also be done using a spreadsheet orin R. You can specify input in terms of Cohen's d.

Reference:

Dunlop, W. P., Cortina, J. M., Vaslow, J. B., & Burke, M. J. (1996). Meta-analysis of experiments with matched groups or repeated measures designs. Psychological Methods, 1, 170-177.

[COPY AND PASTE THE SYNTAX BELOW INTO A SPSS SYNTAX WINDOW AND RUN; ADJUST DATA INPUT VALUES AS REQUIRED]

DATA LIST free
/alpha mdiff sd rho power. 
BEGIN DATA. 
.05 2.0 4.0 0.75 0.90
.05 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.

In R we need just one line:

For an average paired difference (delta) of 0.2, a difference s.d. (sd) of 1, a power of 0.8 and a two-sided type I error (sig.level) of 0.05 we find that 199 pairs are needed.

power.t.test(delta=0.2,sd=1,power=0.8,sig.level=0.05,type=c("paired"),alternative=c("two.sided"))