Diff for "FAQ/power/rmPowN" - CBU statistics Wiki
location: Diff for "FAQ/power/rmPowN"
Differences between revisions 40 and 41
Revision 40 as of 2007-02-19 17:26:24
Size: 3898
Editor: PeterWatson
Comment:
Revision 41 as of 2007-02-19 17:26:44
Size: 3899
Editor: PeterWatson
Comment:
Deletions are marked like this. Additions are marked like this.
Line 27: Line 27:
Computation may also be performed using a [attachment:anova.xls spreadsheet.] Computation may also be performed using a [attachment:anovan.xls spreadsheet.]
  • alpha is likelihood of making a type I error (usually = 0.05)
  • etasq is partial eta-squared/100 so, for example, 5.9% = 0.059

Partial Eta-squared = 

SS(effect) divided by the sum of the SS(effect) and SS(its error) 

or, in other words, the proportion of variance in outcome predicted by the effect after adjusting for other terms in the anova

For B between subject factors with levels $$b_{i}$$, i=1, ..., B and W with subject factors with levels $$w_{j}$$, j=1, ..., W

  • num(erator) = $$ \prod_{\mbox{factors}} $$ (number of levels of factor -1) in term of interest
  • d1 = $$\sum_{i}^{B} (b_{i} - 1) $$ if B > 0 in anova

    • = 0 otherwise
  • d2 = $$ \prod_{j} (w_{j} - 1) $$ if W > 0 in term of interest

    • = 1 otherwise
  • prod = number of combinations of within subject levels
  • power is the power of the test

Computation may also be performed using a [attachment:anovan.xls spreadsheet.]

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

DATA LIST free
/alpha etasq num d1 d2 prod power. 
BEGIN DATA. 
.05 0.059 2 1 2 3 0.85
.05 0.059 2 1 2 3 0.85
END DATA.

matrix.
get m /variables=alpha etasq num d1 d2 prod power  /missing=omit.
compute alpha=make(1,1,0).
compute etasq=make(1,1,0).
compute num=make(1,1,0).
compute d1=make(1,1,0).
compute d2=make(1,1,0).
compute power=make(1,1,0).
compute prod=make(1,1,0).
compute alpha=m(:,1).
compute etasq=m(:,2).
compute num=m(:,3).
compute d1=m(:,4).
compute d2=m(:,5).
compute power=m(:,6).
end matrix.


define apow   (!pos !tokens(1)
                   / !pos !tokens(1)
                   / !pos !tokens(1)
                   / !pos !tokens(1)
                   / !pos !tokens(1)
                   / !pos !tokens(1)
                   / !pos !tokens(1)).

COMPUTE #POW = !6.

compute #conf = (1-!1).
compute #lc3 = 1.
compute #ind=0.
compute prod=!7.
compute ntot = 700.000.
comment COMPUTE #LC1 = 2.000.
compute denom=(ntot-1-!4)*!5.
COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,ntot*prod**!2/(1-!2)).
COMPUTE #DIFF=1.
SET MXLOOPS=10000.
LOOP IF (#DIFF GT .00005) .
+       DO IF (#CUMF2 GT #pow) .
+               COMPUTE #LC3 = ntot.
+               COMPUTE ntot = (Ntot - rnd(1)).
+                      COMPUTE denom=(ntot-1-!4)*!5.                      
+               COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,ntot*prod*!2/(1-!2)).
+       ELSE .
+               COMPUTE #LC1 = ntot.
+               COMPUTE ntot = (ntot + #LC3)/2.
+                      COMPUTE denom=(ntot-1-!4)*!5.
+               COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,ntot*prod*!2/(1-!2)).
+          END IF. 
+       COMPUTE #DIFF = ABS(#CUMF2 - #pow) .
END LOOP .
compute pow2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,ntot*prod*!2/(1-!2)).
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 etasq=!2.
compute num=!3.
compute d1=!4.
compute d2=!5.
compute power=!6.
compute denom=(ntot-1-d1)*d2.
formats ntot (f7.0) alpha (f5.2) num (f5.2) denom (f5.2) etasq (f5.2) power (f5.2).
variable labels ntot 'Total Sample Size Required' /alpha 'Alpha' /num 'Numerator' /denom 'Denominator' /etasq 'Partial Eta-Sq' /power 'Power'.
report format=list automatic align(center)
  /variables=ntot alpha num denom etasq power 
  /title "Anova term sample size for given power (any anova)" .
!enddefine.
matrix.
get m /variables=alpha etasq num d1 d2 power  /missing=omit.
compute alpha=make(1,1,0).
compute etasq=make(1,1,0).
compute num=make(1,1,0).
compute d1=make(1,1,0).
compute d2=make(1,1,0).
compute power=make(1,1,0).
compute alpha=m(:,1).
compute etasq=m(:,2).
compute num=m(:,3).
compute d1=m(:,4).
compute d2=m(:,5).
compute power=m(:,6).
end matrix.
apow alpha etasq num d1 d2 power prod.

None: FAQ/power/rmPowN (last edited 2016-01-05 11:49:58 by PeterWatson)