The initial data are represented as a series of K RxC contingency table s, where K is the number of strata and at least one of the variables ("group", "response") takes on more than 2 values. The null hypothesis is that the two nominal variables that are tested within each repetition are independent of each other; having one value of one variable does not mean that it's more likely that you'll have one value of the second variable
The test statistic is the M^{2} statistic given by:
M² = [Σ_{k} (n_{11k} n_{1+k}/ n_{++k})1/2]² / [Σ_{k} (n_{1+k} n_{2+k} n_{+1k} n_{+2k})/( n_{++k}²( n_{++k}²1))]
The numerator is the difference between observed and expected value and becomes bigger when the difference becomes bigger or variance gets smaller. The null hypothesis is rejected if the proportions remain the same.
Example:
McDonald and Siebenaller (1989) surveyed allele frequencies at the Lap locus in the musselMytilus trossulus on the Oregon coast. At four estuaries, samples were taken from inside the estuary and from a marine habitat outside the estuary. There were three common alleles and a couple of rare alleles; based on previous results, the biologically interesting question was whether the Lap^{94} allele was less common inside estuaries, so all the other alleles were pooled into a "non94" class.
There are three nominal variables: allele (94 or non94), habitat (marine or estuarine), and area (Tillamook, Yaquina, Alsea, or Umpqua). The null hypothesis is that at each area, there is no difference in the proportion of Lap^{94} alleles between the marine and estuarine habitats, after controlling for area.
This table shows the number of 94 and non94 alleles at each location. There is a smaller proportion of 94 alleles in the estuarine location of each estuary when compared with the marine location; we wanted to know whether this difference is significant.
Location 
Allele 
Marine 
Estuarine 
Tillamook 
94 
56 
69 

non94 
40 
77 
Yaquina 
94 
61 
257 

non94 
57 
301 
Alsea 
94 
73 
65 

non94 
71 
79 
Umpqua 
94 
71 
48 

non94 
55 
48 
Applying the formula given above, the numerator is 355.84, the denominator is 70.47, so the result is χ^{2}_{MH}=5.05, 1 d.f., P=0.025. You can reject the null hypothesis that the proportion ofLap^{94} alleles is the same in the marine and estuarine locations.