FAQ/power/owAnovaN - CBU statistics Wiki

Revision 24 as of 2007-03-06 09:56:16

Clear message
location: FAQ / power / owAnovaN

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

This program uses R-squared, the multiple correlation, as the effect size, which may also be expressed as Cohen's f= R-sq/(1-R-sq) (see http://en.wikipedia.org/wiki/Effect_size#Cohen.27s_d) as an effect size in regressions including one-way anovas as a special case.

From Cohen(1977, 1992) it follows R-squareds of 0.01, 0.0588 and 0.138 are suggested conventions for small, medium and large effect size.

Alpha is the type I error, df of the effect, dfe, is the total degrees of freedom for the predictors of interest, df of the confounders, dfc, is the total number of degrees of freedom of the other predictors in the multiple regression, rsq is the multiple correlation with given power. The program then outputs the total sample size required. This can also be done using a [attachment:owanov.xls spreadsheet].

df for each predictor equals k -1 for a group predictor with k levels or 1 for each continuous predictor.

DATA LIST free
/alpha dfe dfc rsq power. 
BEGIN DATA. 
.05 2 1 0.3 0.90
END DATA. 

set errors=none.
define owanov ( !pos !tokens(1)
                   /!pos !tokens(1)
                   /!pos !tokens(1)
                   /!pos !tokens(1)
                   /!pos !tokens(1)).

COMPUTE #POW = !5.

compute #conf = (1-!1).
compute #lc3 = 1.
compute #ind=0.
compute ntot = 15.000.
comment COMPUTE #LC1 = 2.000.
COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!2,ntot-!2-!3-1),!2,NTOT-!2-!3-1,NTOT*!4/(1-!4)).
COMPUTE #DIFF = 1 .
SET MXLOOPS=10000.
LOOP IF (#DIFF GT .00005) .
+       DO IF (#CUMF2 LT #pow) .
+               COMPUTE #LC3 = NTOT .
+               COMPUTE NTOT = (NTOT + rnd(ntot/3)).
+               COMPUTE #CUMF2 =  1 - NCDF.F(IDF.F(#conf,!2,ntot-!2-!3-1),!2,NTOT-!2-!3-1,NTOT*!4/(1-!4)).

+       ELSE .
+               COMPUTE #LC1 = ntot .
+               COMPUTE ntot = (ntot + #LC3)/2 .
+               COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!2,ntot-!2-!3-1),!2,NTOT-!2-!3-1,NTOT*!4/(1-!4)).

+       END IF .
+       COMPUTE #DIFF = ABS(#CUMF2 - #pow) .
END LOOP .
if (ntot-trunc(ntot) gt 0.5) #ind=1.
if (#ind eq 0) ntot=trunc(ntot)+1.
if (#ind eq 1) ntot=rnd(ntot).
EXECUTE .
compute alpha=!1.
compute dfe=!2.
compute dfc=!3.
compute rsq=!4.
compute power=#pow.
formats ntot (f7.0) alpha (f5.2) dfe (f5.2) dfc (f5.2) rsq (f5.2) power (f5.2).
variable labels ntot 'Total Sample Size Required' /alpha 'Alpha' /dfe 'Df effect' /dfc 'Df confounders' /rsq 'R-Squared' /power 'Power'.
report format=list automatic align(center)
  /variables=ntot alpha dfe dfc rsq power 
  /title "Multiple regression sample size for given power" .
!enddefine.
matrix.
get m /variables=alpha g rsq power  /missing=omit.
compute alpha=make(1,1,0).
compute dfe=make(1,1,0).
compute dfc=make(1,1,0).
compute rsq=make(1,1,0).
compute power=make(1,1,0).
compute alpha=m(:,1).
compute dfe=m(:,2).
compute dfc=m(:,3).
compute rsq=m(:,4).
compute power=m(:,5).  
end matrix.
owanov alpha dfe dfc rsq power.