A test, introduced by McNemar in 1947, for use with paired data when the observed variable is dichotomous (see categorical variable). Suppose, for example, that competing drugs (A and B) are tested on pairs of patients. The outcome is either success or failure. Information about the relative merits of the drugs is provided only by occasions where just one is successful. Let a denote the number of pairs in which only drug A succeeds, and b denote the number of pairs in which only drug B succeeds. With a continuity correction, McNemar's test statistic is
which, if the drugs are really equally effective, may be taken to be an observation from a chi-squared distribution with one degree of freedom. The generalization to more than two matched samples is provided by the Cochran Q test.