|
Size: 4055
Comment:
|
← Revision 90 as of 2016-01-05 11:49:58 ⇥
Size: 5352
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| __Spreadsheet and SPSS macro inputs__ | |
| Line 2: | Line 3: |
| * alpha is likelihood of making a type I error (usually = 0.05) | * alpha is the likelihood of making a type I error (usually = 0.05) |
| Line 8: | Line 9: |
| where SS is the sum of squares associated with a particular term in the anova. | |
| Line 9: | Line 11: |
| In other words, partial $$\eta^text(2)$$ represents the proportion of variance in outcome predicted by the effect after adjusting for other terms in the anova. Click [[attachment:etasqrp.pdf|here]] for further details on partial $$\eta^text{2}$$ and [[attachment:etasq.pdf|here.]] If SS are not available you can [[FAQ/power/rsqform| construct eta-squared]]. |
|
| Line 10: | Line 14: |
| or, in other words, the proportion of variance in outcome predicted by the effect after adjusting for other terms in the anova. [attachment:etasqrp.pdf Click here for further details on partial $$\eta^text{2}$$] and [attachment:etasq.pdf here.] | * correlation = average correlation between repeated measures levels |
| Line 12: | Line 16: |
| * num(erator) = df of term of interest = the product of the (number of levels of each factor -1) in term of interest | |
| Line 13: | Line 18: |
| For B between subject factors with levels $$b_{i}$$, i=1, ..., B and W with subject factors with levels $$w_{j}$$, j=1, ..., W | * sum (B-1) = sum of dfs involving '''only''' between subject factors in anova or zero otherwise. df = Product of number of levels minus 1 of each between subject factor in term of interest. e.g. For a three way interaction involving three between subject factors, abc, we sum the dfs of the six lower order combinations: ab, ac and bc, a, b and c to that of abc. |
| Line 15: | Line 20: |
| * num(erator) = $$ \prod_{\mbox{factors}} $$ (number of levels of factor -1) in term of interest | * Prod (W-1) = df of within subject effect if in term of interest or 1 otherwise. df = Product of number of levels minus 1 of each within subject factor in term of interest |
| Line 17: | Line 22: |
| * 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 |
* Prod W = product of all within subject levels or one if there are none. |
| Line 27: | Line 26: |
| [:FAQ/powexample: Example input] | [[FAQ/power/powexample| Example input]] |
| Line 29: | Line 28: |
| Computation may also be performed using a [attachment:anovan.xls spreadsheet.] | Computation may be performed using an EXCEL [[attachment:anovan2.xls|spreadsheet]] or the below SPSS syntax. Power analysis software using Winer (1991, pp 136-138) for balanced anovas may be downloaded from [[http://www.soton.ac.uk/~cpd/anovas/datasets/|here]] with details of how to compute inputs [[FAQ/Doncaster| here.]] |
| Line 35: | Line 34: |
| /alpha etasq num d1 d2 prod power. | /alpha etasq num bsum wdf corr power. |
| Line 37: | Line 36: |
| .05 0.059 2 1 2 3 0.85 .05 0.059 2 1 2 3 0.85 |
.05 0.059 2 1 2 0.3 0.85 .05 0.059 2 1 2 0.0 0.85 |
| Line 42: | Line 41: |
| get m /variables=alpha etasq num d1 d2 prod power /missing=omit. | get m /variables=alpha etasq num bsum wdf corr power /missing=omit. |
| Line 46: | Line 45: |
| compute d1=make(1,1,0). compute d2=make(1,1,0). |
compute bsum=make(1,1,0). compute wdf=make(1,1,0). compute corr=make(1,1,0). |
| Line 49: | Line 49: |
| compute prod=make(1,1,0). | |
| Line 53: | Line 52: |
| compute d1=m(:,4). compute d2=m(:,5). compute power=m(:,6). |
compute bsum=m(:,4). compute wdf=m(:,5). compute corr=m(:,6). compute power=m(:,7). |
| Line 64: | Line 64: |
| / !pos !tokens(1) | / !pos !tokens(1) |
| Line 67: | Line 67: |
| COMPUTE #POW = !6. | COMPUTE #POW = !7. |
| Line 72: | Line 72: |
| compute prod=!7. | |
| Line 76: | Line 75: |
| COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,ntot*prod**!2/(1-!2)). | COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,(denom*(!2/(1-!2)))/(1-!6)). |
| Line 84: | Line 83: |
| + COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,ntot*prod*!2/(1-!2)). | + COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,(denom*(!2/(1-!2)))/(1-!6)). |
| Line 89: | Line 88: |
| + COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,ntot*prod*!2/(1-!2)). | + COMPUTE #CUMF2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,(denom*(!2/(1-!2)))/(1-!6)). |
| Line 93: | Line 92: |
| compute pow2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,ntot*prod*!2/(1-!2)). | compute pow2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,(denom*(!2/(1-!2)))/(1-!6)). |
| Line 101: | Line 100: |
| 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'. |
compute bsum=!4. compute wdf=!5. compute corr=!6. compute power=!7. compute denom=(ntot-1-bsum)*wdf. formats ntot (f7.0) alpha (f5.2) num (f5.2) denom (f5.2) etasq (f5.2) corr (f5.2) power (f5.2). variable labels ntot 'Total Sample Size Required' /alpha 'Alpha' /num 'Numerator' /denom 'Denominator' /etasq 'Partial Eta-Sq' /corr 'Correlation' /power 'Power'. |
| Line 108: | Line 108: |
| /variables=ntot alpha num denom etasq power | /variables=ntot alpha num denom etasq corr power |
| Line 112: | Line 112: |
| get m /variables=alpha etasq num d1 d2 power /missing=omit. | get m /variables=alpha etasq num bsum wdf corr power /missing=omit. |
| Line 116: | Line 116: |
| compute d1=make(1,1,0). compute d2=make(1,1,0). |
compute bsum=make(1,1,0). compute wdf=make(1,1,0). compute corr=make(1,1,0). |
| Line 122: | Line 123: |
| compute d1=m(:,4). compute d2=m(:,5). compute power=m(:,6). |
compute bsum=m(:,4). compute wdf=m(:,5). compute corr=m(:,6). compute power=m(:,7). |
| Line 126: | Line 128: |
| apow alpha etasq num d1 d2 power prod. | apow alpha etasq num bsum wdf corr power. |
| Line 129: | Line 131: |
| __Reference__ Doncaster CP and Davey AJH (2007) Analysis of covariance. How to choose and construct models for the life sciences. CUP:Cambridge. Winer BJ, Brown DR and Michels KM (1991) Statistical principles in experimental design, 3rd edition. McGraw-Hill:New York. |
Spreadsheet and SPSS macro inputs
- alpha is the likelihood of making a type I error (usually = 0.05)
- etasq is partial $$\eta^text{2}$$/100 so, for example, 5.9% = 0.059
Partial $$\eta^text{2}$$ = $$ \frac{\mbox{SS(effect)}}{\mbox{SS(effect) + SS(its error)}}$$ where SS is the sum of squares associated with a particular term in the anova.
In other words, partial $$\eta^text(2)$$ represents the proportion of variance in outcome predicted by the effect after adjusting for other terms in the anova. Click here for further details on partial $$\eta^text{2}$$ and here. If SS are not available you can construct eta-squared.
- correlation = average correlation between repeated measures levels
- num(erator) = df of term of interest = the product of the (number of levels of each factor -1) in term of interest
sum (B-1) = sum of dfs involving only between subject factors in anova or zero otherwise. df = Product of number of levels minus 1 of each between subject factor in term of interest. e.g. For a three way interaction involving three between subject factors, abc, we sum the dfs of the six lower order combinations: ab, ac and bc, a, b and c to that of abc.
- Prod (W-1) = df of within subject effect if in term of interest or 1 otherwise. df = Product of number of levels minus 1 of each within subject factor in term of interest
- Prod W = product of all within subject levels or one if there are none.
- power is the power of the test
Computation may be performed using an EXCEL spreadsheet or the below SPSS syntax. Power analysis software using Winer (1991, pp 136-138) for balanced anovas may be downloaded from here with details of how to compute inputs here.
[ 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 bsum wdf corr power.
BEGIN DATA.
.05 0.059 2 1 2 0.3 0.85
.05 0.059 2 1 2 0.0 0.85
END DATA.
matrix.
get m /variables=alpha etasq num bsum wdf corr power /missing=omit.
compute alpha=make(1,1,0).
compute etasq=make(1,1,0).
compute num=make(1,1,0).
compute bsum=make(1,1,0).
compute wdf=make(1,1,0).
compute corr=make(1,1,0).
compute power=make(1,1,0).
compute alpha=m(:,1).
compute etasq=m(:,2).
compute num=m(:,3).
compute bsum=m(:,4).
compute wdf=m(:,5).
compute corr=m(:,6).
compute power=m(:,7).
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 = !7.
compute #conf = (1-!1).
compute #lc3 = 1.
compute #ind=0.
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,(denom*(!2/(1-!2)))/(1-!6)).
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,(denom*(!2/(1-!2)))/(1-!6)).
+ 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,(denom*(!2/(1-!2)))/(1-!6)).
+ END IF.
+ COMPUTE #DIFF = ABS(#CUMF2 - #pow) .
END LOOP .
compute pow2 = 1 - NCDF.F(IDF.F(#conf,!3,denom),!3,denom,(denom*(!2/(1-!2)))/(1-!6)).
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 bsum=!4.
compute wdf=!5.
compute corr=!6.
compute power=!7.
compute denom=(ntot-1-bsum)*wdf.
formats ntot (f7.0) alpha (f5.2) num (f5.2) denom (f5.2) etasq (f5.2) corr (f5.2) power (f5.2).
variable labels ntot 'Total Sample Size Required' /alpha 'Alpha' /num 'Numerator' /denom 'Denominator' /etasq 'Partial Eta-Sq' /corr 'Correlation' /power 'Power'.
report format=list automatic align(center)
/variables=ntot alpha num denom etasq corr power
/title "Anova term sample size for given power (any anova)" .
!enddefine.
matrix.
get m /variables=alpha etasq num bsum wdf corr power /missing=omit.
compute alpha=make(1,1,0).
compute etasq=make(1,1,0).
compute num=make(1,1,0).
compute bsum=make(1,1,0).
compute wdf=make(1,1,0).
compute corr=make(1,1,0).
compute power=make(1,1,0).
compute alpha=m(:,1).
compute etasq=m(:,2).
compute num=m(:,3).
compute bsum=m(:,4).
compute wdf=m(:,5).
compute corr=m(:,6).
compute power=m(:,7).
end matrix.
apow alpha etasq num bsum wdf corr power.Reference
Doncaster CP and Davey AJH (2007) Analysis of covariance. How to choose and construct models for the life sciences. CUP:Cambridge.
Winer BJ, Brown DR and Michels KM (1991) Statistical principles in experimental design, 3rd edition. McGraw-Hill:New York.
