Skip to content

Can I use "mcnemar.test" for 3*3 tables (or is there a bug in the command?)

2 messages · Kyungmin Ko, Peter Dalgaard

#
As Peter Dalgaard and jchavez12 (on Nabble) pointed out,
"mcnemar.test" does McNemar-Bowker test (Bowker's test) which tests
symmetry, not marginal homogeneity.
Marginal homogeneity and symmetry are equivalent in 2x2 matrices but
not for larger tables.
I also was confused because many resources (for example Wikipedia
accessed 2020-08-30) introduce McNemar's test as a test of marginal
homogeneity (which it is only for 2x2 matrices).
The R Reference Manual entry for mcnemar.test states that it tests for symmetry.
The code for mcnemar.test is also consistent with the McNemar-Bowker
test for symmetry.
Since the function does what the manual states it does, I would not
call this a bug.
Although, I would like it if the result of mcnemar.test would print
"McNemar's Chi-squared test of symmetry" rather than just "McNemar's
Chi-squared test."
mcnemar.test often fails for sparse matrices, because symmetric zeros
produce a NaN due to division by zero in the following line of
mcnemar.test code:
STATISTIC <- sum(y[upper.tri(x)]^2/x[upper.tri(x)])
The McNemar-Bowker test uses Chi-squared approximation, which would
not be good for small counts (and sparse matrices).
mcnemar.test does not perform continuity correction for matrices
larger than 2x2.
Is there an exact test for symmetry of matrices larger than 2x2?
I could not find one.
I would not call this a bug.
This behavior of giving "NA" due to a division by zero seems to be
consistent across statistical tests in R.
For example chisq.test(matrix(c(0, 0, 1, 2), nrow = 2) gives NA.
You have the option of the McNemar-Bowker test for symmetry
(mcnemar.test), and Stuart-Maxwell test (mh_test).
As an "indicator that the general response to the experimental
settings was different for the kids,"
I would think that if marginal homogeneity is rejected, the two tests
are not equivalent.
I would run mh_test with distribution = "exact" .
The relationship between symmetry and equivalence of two tests is not
as clear to me.
I suppose if the two experimental settings are equivalent and the
distribution of random error for each test are also the same the
resulting matrix would be symmetric?

R 4.0.2 . coin 1.3.1 .
#
Um, that was on July 19, 2009.....
The exact test for the 2x2 case is isomorphic to a binomial test of the two off-diagonal elements (conditioning on the sum).

The natural way of constructing a test for the k x k case would be based on the Cartesian product of k(k-1)/2 binomials with p=.5, (one for each i,j-combination). This shouldn't be too hard if k is small, but of course it explodes combinatorially as k increases.

-pd