1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
(Q) I want to test whether there is a significant decrease of smoking
 status in a sample over a timespan. I would like to use
 McNemar-ChiSquare-Test with the following syntax:

NPAR TEST
  /MCNEMAR=smoke1 WITH smoke2 (PAIRED)
  /STATISTICS DESCRIPTIVES
  /MISSING ANALYSIS.

But I don№t get a ChiSquare-Value: I only get the probabilities (exact sig.
2-tailed). Can somebody tell me how to get the McNemar-ChiSquare value?

(A) Posted to SPSSX-L list by Marta Garcia-Granero on 2005/01/04
 If sample size is low (less than 25 discordant pairs *), NPAR TEST
 /MCNEMAR will always give the exact p-value. If the number of
 discordant pairs is GE 10, then Chi-square test (uncorrected and
 corrected) can be used instead. By the way, McNemar test can be
 obtained in SPSS with CROSSTABS too (it gives the exact p value for
 very big sample sizes).

(*) Discordant pairs: smoke1=0/smoke2=1 and smoke1=1/smoke2=0.
 Note: The code assumes all 4 combinations exist in data.

Here's a solution:

* Simulated data (replace by your own) *.
DATA LIST FREE/ smoke1 smoke2 (2 F8.0).
BEGIN DATA
1 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 0 0 1 1
1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 0 1 0 1 0
0 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 1 1 1 1
1 1 0 1 1 0 0 0 0 0 1 1 1 1 1 1 0 0 1 1
0 0 1 0 1 0 1 0 1 1 1 1 1 1 0 0 1 1 1 0
END DATA.

VALUE LABELS smoke1 smoke2 0 'No' 1 'Yes'.

* McNemar's exact test with SPSS (using CROSSTABS) *.

CROSSTABS
  /TABLES=smoke1 BY smoke2
  /STATISTIC=MCNEMAR.

* McNemar's Chi-square tests (using MATRIX) *.

TEMPORARY.
SELECT IF (NOT MISSING(smoke1) AND NOT MISSING(smoke2)).
AGGREGATE
  /OUTFILE='c:\\temp\\aggr.sav'
  /BREAK=smoke1 smoke2
  /N=N.

MATRIX.
PRINT/TITLE="MC-NEMAR'S CHI-SQUARE (CORRECTED & UNCORRECTED)".
GET obs /VAR=n /FILE='c:\\temp\\aggr.sav' /MISSING=0.
COMPUTE a=obs(1).
COMPUTE b=obs(2).
COMPUTE c=obs(3).
COMPUTE d=obs(4).
RELEASE obs.
PRINT {a,b,a+b;c,d,c+d;a+c,b+d,a+b+c+d}
 /FORMAT='F8.0'
 /RLABEL='A-','A+','Total'
 /CLABEL='B-','B+','Total'
 /TITLE='INPUT DATA'.
* Corrected & Uncorrected Chi-Square values *.
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).
PRINT {chi2,chi2sig;chi2cor,chi2sigc}
 /FORMAT='F8.4'
 /CLABELS='Chi^2','Sig.'
 /RLABELS='Uncorr.','Correct.'
 /TITLE="Chi-square tests (df=1) & asymptotic significance".
END MATRIX.