|
Size: 2696
Comment:
|
Size: 2695
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 7: | Line 7: |
| Alpha is the type I error, g is the number of groups in the (between subjects) one-way anova or, alternatively, one more than the number of predictor variables in a 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:owanR.xls spreadsheet]. | Alpha is the type I error, g is the number of groups in the (between subjects) one-way anova or, alternatively, one more than the number of predictor variables in a 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:owan.xls spreadsheet]. |
[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, g is the number of groups in the (between subjects) one-way anova or, alternatively, one more than the number of predictor variables in a 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:owan.xls spreadsheet].
DATA LIST free
/alpha g rsq power.
BEGIN DATA.
.05 3 0.3 0.90
END DATA.
set errors=none.
define owanov ( !pos !tokens(1)
/!pos !tokens(1)
/!pos !tokens(1)
/!pos !tokens(1)).
COMPUTE #POW = !4.
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-1,ntot-!2),!2-1,NTOT-!2,NTOT*!3/(1-!3)).
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-1,ntot-!2),!2-1,NTOT-!2,NTOT*!3/(1-!3)).
+ ELSE .
+ COMPUTE #LC1 = ntot .
+ COMPUTE ntot = (ntot + #LC3)/2 .
+ COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!2-1,ntot-!2),!2-1,NTOT-!2,NTOT*!3/(1-!3)).
+ 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 g=!2.
compute rsq=!3.
compute power=!4.
formats ntot (f7.0) alpha (f5.2) g (f5.2) rsq (f5.2) power (f5.2).
variable labels ntot 'Total Sample Size Required' /alpha 'Alpha' /g 'No. Groups' /rsq 'R-Squared' /power 'Power'.
report format=list automatic align(center)
/variables=ntot alpha g rsq power
/title "One way ANOVA sample size for given power" .
!enddefine.
matrix.
get m /variables=alpha g rsq power /missing=omit.
compute alpha=make(1,1,0).
compute g=make(1,1,0).
compute rsq=make(1,1,0).
compute power=make(1,1,0).
compute alpha=m(:,1).
compute g=m(:,2).
compute rsq=m(:,3).
compute power=m(:,4).
end matrix.
owanov alpha g rsq power.