FAQ/power/mcnemarN - CBU statistics Wiki
location: / mcnemarN

The program calculates the power for doing the McNemar test (see also here). P12 is the proportion of respondents you expect to change from group '1' to group '2' (the proportion which are in cell 12) and p21 the proportion of people you expect to change from group '2' to group '1'. Give the number of cases as ntot and the type I error is alpha. Power can also be computed using a spreadsheet or in R.

 Time 1 Group 1 2 Time 2 1 p11 p12 2 p21 p22

[COPY AND PASTE CONTENTS OF BOX BELOW INTO A SPSS SYNTAX WINDOW; ADJUST DATA AS REQUIRED]

```DATA LIST free
/p12 p21 ntot alpha.
BEGIN DATA.
0.5 0.2 10 .05
0.5 0.2 10 .10
0.5 0.2 50 .05
0.5 0.2 70 .05
0.5 0.2 70 .10
END DATA.
print errors=none.
matrix.
get m /variables=p12 p21 ntot alpha /missing=omit.
compute p12=make(1,1,0).
compute p21=make(1,1,0).
compute ntot=make(1,1,0).
compute alpha=make(1,1,0).
compute p12=m(:,1).
compute p21=m(:,2).
compute ntot=m(:,3).
compute alpha=m(:,4).
end matrix.
COMPUTE #chisq1 = ((p12-p21)**2)/(p12+p21).
compute #df=1.
compute #conf = 1-alpha.
compute #chisq=ntot*#chisq1.
compute power = 1 - NCDF.CHISQ(IDF.CHISQ(#conf,#DF),#DF,#CHISQ).
formats p12 (f5.2) p21 (f5.2) alpha (f5.2) ntot (f5.2) power (f5.2).
variable labels p12 'Prop 12' /p21 'Prop 21' /alpha 'Two-Tailed Alpha' /ntot 'Total Number of Pairs' /power 'Power'.
report format=list automatic align(center)
/variables=p12 p21 alpha ntot power
/title "Power for given sample size for McNemar's test from a 2x2 table of proportions" .```

None: FAQ/power/mcnemarN (last edited 2013-03-08 10:17:36 by localhost)