[ top | up ]

McNemar's Chi-square Test for Count Data

Usage

mcnemar.test(x, y = NULL, correct = TRUE)

Arguments

x either a two-dimensional contingency table in matrix form, or a factor object.
y a factor object; ignored if x is a matrix.
correct a logical indicating whether to apply continuity correction when computing the test statistic.

Description

mcnemar.test performs an McNemar's chi-square test for symmetry of rows and columns in a two-dimensional contingency table. The null is that the probabilities of being classified into cells [i,j] and [j,i] are the same.

If x is a matrix, it is taken as a two-dimensional contingency table, and hence its entries should be nonnegative integers. Otherwise, both x and y must be vectors of the same length. Incomplete cases are removed, the vectors are coerced into factor objects, and the contingency table is computed from these.

Continuity correction is only used in the 2-by-2 case if correct is TRUE.

Value

A list with class "htest" containing the following components:
statistic the value of McNemar's statistic.
parameter the degrees of freedom of the approximate chi-square distribution of the test statistic.
p.value the p-value of the test.
method a character string indicating the type of test performed, and whether continuity correction was used.
data.name a character string giving the name(s) of the data.