## Pages

### Two Proportions Test (Related) - SPSS

Testing two (repeated measures) proportions in SPSS is not an obvious procedure. In fact, it can actually be done by the McNemar Test, however, I would caution against doing so. The main reason is that SPSS applies an unnecessarily conservative correction to the McNemar test (known as Yates' correction). Unfortunately, one can not chose to obtain the results without the Yates' correction, hence the great utility of the macro below, which was created by Marta Garcia-Granero (I made some minor changes to the macro, which include changing the language of the output to English). Not only does the macro provide the McNemar results with and without the correction, it also provides the 95% confidence intervals associated with the change in proportions/percentages.

Although the macro was written by Marta Garcia-Granero, the confidence intervals are based on a procedure described by Newcombe (1998).

To learn how to use the macro below (despite appearances, it's very easy), check out this video:

Parts:

References

Newcombe, R. G. (1998). Interval estimation for the difference between independent proportions: Comparison of eleven methods. Statistics in Medicine, 17, 873-890.

-----------------------------------------------------------------------------------------
* MACRO definition (it also computes a 95%CI -Newcombe's method- for the difference in percentages, nice extra!) *.
DEFINE MYMCNEMAR(!POSITIONAL !TOKENS(1) /!POSITIONAL
!TOKENS(1)/!POSITIONAL !TOKENS(1)/!POSITIONAL !TOKENS(1)).
DATASET NAME Datos.
DATASET DECLARE Results1 WINDOW=HIDDEN.
DATASET DECLARE Results2 WINDOW=HIDDEN.
PRESERVE.
SET ERRORS=NONE RESULTS=NONE.
MATRIX.
COMPUTE nanb=!1 .
COMPUTE napb=!2 .
COMPUTE panb=!3 .
COMPUTE papb=!4 .
COMPUTE a=nanb.
COMPUTE b=napb.
COMPUTE c=panb.
COMPUTE d=papb.
COMPUTE perc={(c+d)/(a+b+c+d);(b+d)/(a+b+c+d)}.
COMPUTE chi2=((b-c)**2)&/(b+c).
COMPUTE chi2sig=1-CHICDF(chi2,1).
COMPUTE chi2cor=(ABS(b-c)-1)**2&/(b+c).
COMPUTE chi2sigc=1-CHICDF(chi2cor,1).
COMPUTE z = 1.959964.
COMPUTE zsq = 1.959964*1.959964.
COMPUTE x5=papb+panb.
COMPUTE x6=napb+nanb.
COMPUTE x7=papb+napb.
COMPUTE x8=panb+nanb.
COMPUTE x9=x7+x8.
COMPUTE x10=(panb-napb)/x9.
COMPUTE x11=2*x5+zsq.
COMPUTE x12=z&*(zsq+4*x5&*x6/x9)&**0.5.
COMPUTE x13=2*(x9+zsq).
COMPUTE x14=(x11+x12)/x13.
COMPUTE x15=(x11-x12)/x13.
COMPUTE x16=x5/x9-x15.
COMPUTE x17=x14-x5/x9.
COMPUTE x21=2*x7+zsq.
COMPUTE x22=z&*(zsq+4*x7&*x8/x9)&**0.5.
COMPUTE x24=(x21+x22)/x13.
COMPUTE x25=(x21-x22)/x13.
COMPUTE x26=x7/x9-x25.
COMPUTE x27=x24-x7/x9.
COMPUTE x29=x5&*x6&*x7&*x8.
COMPUTE x30=1.
DO IF x29 EQ 0.
- COMPUTE x30=0.
END IF.
COMPUTE x31=papb&*nanb-panb&*napb.
COMPUTE x32=0.
DO IF (x31 GT 0).
- COMPUTE x32=1.
END IF.
COMPUTE x33=x31-x9/2.
COMPUTE x35=0.
DO IF (x33 GT 0).
- COMPUTE x35=x33.
END IF.
COMPUTE x36=x32&*x35+(1-x32)&*x31.
COMPUTE x37=x30&*x36.
COMPUTE x38=x30&*x29&**0.5+(1-x30).
COMPUTE x39=x37/x38. /* phi hat.
COMPUTE x40=x16&*x16-2*x39&*x16&*x27+x27&*x27.
COMPUTE x41=x17&*x17-2*x39&*x17&*x26+x26&*x26.
COMPUTE x42=x10-SQRT(x40).
COMPUTE x43=x10+SQRT(x41).
COMPUTE vnames={'P1','P2','Puntual','Lower.CI','Upper.CI'}.
SAVE {100*T(perc),100*x10,100*x42,100*x43} /OUTFILE=Results1
/NAMES=vnames.
COMPUTE vnames={'Chi2','Sig'}.
SAVE {chi2,chi2sig;chi2cor,chi2sigc} /OUTFILE=Results2 /NAMES=vnames.
END MATRIX.
RESTORE.
DATASET ACTIVATE Results1.
FORMAT P1 TO Upper.CI (PCT4.2).
VAR LABEL P1 'Percent A'/P2 'Percent B'/ Puntual 'Difference'.
OMS /SELECT TABLES
/IF COMMANDS='Summarize' SUBTYPES='Case Processing Summary'
/DESTINATION VIEWER=NO.
SUMMARIZE
/TABLES=ALL
/FORMAT=LIST NOCASENUM NOTOTAL
/TITLE='95%CI for difference in proportions (paired) (*)'
/CELLS=NONE.
OMSEND.
ECHO '(*) Exact (As per Newcombe, 1998)'.
DATASET ACTIVATE Results2.
DATASET CLOSE Results1.
FORMAT chi2(F8.3) Sig (F8.4).
VAR LABEL chi2 'Chi-Square'/ Sig 'Sig.'.
STRING Test (A12).
IF (\$casenum EQ 1) Test = 'Uncorrected' .
IF (\$casenum EQ 2) Test = 'Corrected*' .
OMS /SELECT TABLES
/IF COMMANDS='Summarize' SUBTYPES='Case Processing Summary'
/DESTINATION VIEWER=NO.
SUMMARIZE
/TABLES=Test chi2 Sig
/FORMAT=LIST NOCASENUM NOTOTAL
/TITLE='McNemar Chi-square statistics'
/CELLS=NONE.
OMSEND.
DATASET ACTIVATE Datos.
DATASET CLOSE Results2.
ECHO '(*) Corrected for continuity; this correction is too conservative in most cases.'
!ENDDEFINE.

* An example of the macro call: suppose your crosstab table output (from
SPSS' McNemar output)
looks like this:
*      No   Yes
* No   14    2
* Yes   8    9

MYMCNEMAR 14 2 8 9.