Diff for "FAQ/power/mcnemarN" - CBU statistics Wiki
location: Diff for "FAQ/power/mcnemarN"
Differences between revisions 2 and 4 (spanning 2 versions)
Revision 2 as of 2006-09-19 14:23:19
Size: 1054
Editor: PeterWatson
Comment:
Revision 4 as of 2006-09-19 14:29:35
Size: 1442
Editor: PeterWatson
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

The program calculates the power for doing the McNemar test
(see also http://home.clara.net/sisa/powhlp.htm). 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.

[COPY AND PASTE INTO A SYNTAX WINDOW; ADJUST DATA AS REQUIRED]

The program calculates the power for doing the McNemar test (see also http://home.clara.net/sisa/powhlp.htm). 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.

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)