Login  Register

Re: No chi-square value in McNemar test output?

Posted by Marta Garcia-Granero on Feb 13, 2008; 7:40pm
URL: http://spssx-discussion.165.s1.nabble.com/No-chi-square-value-in-McNemar-test-output-tp1080750p1080751.html

Sytske escribió:
>
> I'm using the nonparametric 2 related samples McNemar test in SPSS 15 (NPAR
> TEST), but the output doesn't give me a value for the McNemar chi-square.
> The output gives the crosstab plus a table containing 'N' and 'Exact Sig.
> (2-tailed)'. Why is SPSS not giving the chi-square and how can I get the
> chi-square?
If sample size is low (I recall something like "less than 25 discordant
pairs (0/1 & 1/0 values)"), SPSS will always give the exact p-value. For
big sample sizes, SPSS will give McNemar's Chi-square, but corrected for
continuity. Both tests (exact & continuity corrected) are too
conservative (according to Montecarlo simulations run & published by
someone whose name I don't remember right now). If you have more than 10
discordant pairs, uncorrected chi-square should be used instead. It can
be easily computed from the crosstab table output, and using some MATRIX
code (see MACRO below).

HTH,
Marta García-Granero

* MACRO definition (it also computes a 96%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 Resultados1 WINDOW=HIDDEN.
DATASET DECLARE Resultados2 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','Inferior','Superior'}.
SAVE {100*T(perc),100*x10,100*x42,100*x43} /OUTFILE=Resultados1
/NAMES=vnames.
COMPUTE vnames={'Chi2','Sig'}.
SAVE {chi2,chi2sig;chi2cor,chi2sigc} /OUTFILE=Resultados2 /NAMES=vnames.
END MATRIX.
RESTORE.
DATASET ACTIVATE Resultados1.
FORMAT P1 TO Superior (PCT4.2).
VAR LABEL P1 'Porc. A'/P2 'Porc. B'/ Puntual 'Diferencia'.
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 (Newcombe method)'.
DATASET ACTIVATE Resultados2.
DATASET CLOSE Resultados1.
FORMAT chi2(F8.3) Sig (F8.4).
VAR LABEL chi2 'Chi²'/ 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 Resultados2.
ECHO '(*) Asymptotic'.
!ENDDEFINE.

* An example of the macro call: suppose your crosstab table output (from
SPSS' McNemar output)
   looks like this:
*      No   Yes
* No   10    12
* Yes   4    20

MYMCNEMAR 10 12 4 20.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD