I have two groups of experimental data samples that are categorical, and my goal is similar to Pearson's chi-squared test (${ \chi ^{2}}$), to evaluate how likely it is that any observed difference between the sets arose by chance.

A sample from the first experiment is $D_1 = \{x_{1,1}: n_{1,1}, x_{1,2}: n_{1,2}, ... x_{1,t}: n_{1,t}\}$ and a sample from the second experiment is $D_2 =\{x_{2,1}: n_{2,1}, x_{2,2}: n_{2,2}, ... x_{2,t}: n_{2,t}\}$. ( An example for data samples: $\{CAT: 10, DOG: 22, ... FROG: 44\}$)

Now, lets say I want to compare these data sets using $\chi^2$ test, but I want to stratify the data into different blocks (because observations are taken across time and I want to compare observations done at the same time directly to each other).

More concretely, let's say for each group, I add a block index: $D^b_i = \{x^b_{i,1}: n^b_{i,1}, x^b_{i,2}: n^b_{i,2}, ... x^b_{i,t}: n^b_{i,t}\}$ where $i \in {1, 2}$ and $b$ is the block number. If the data was dichotomous, i.e., $n_i^j$'s were only 0 or 1, I could use Cochran's Q test to compare the two groups.

Is there such a test that generalizes Cochran's Q test to all categorical data and not just dichotomous data?


1 Answer 1


Yes, these are called Generalised (Cochran)-Mantel-Haenszel tests. One implementation (in R) is documented here

This version allows for ordinal variables as well as nominal

These are both score tests for the interaction between your two variables of interest in a loglinear model with main effects for the block and the variables of interest.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.