Introduction
Hello again! In our last lesson, you mastered the practical application of the McNemar test, seeing how it effectively analyzes changes in paired, binary data from a 2x2 table. We ended by asking a critical question: what happens when our paired categories aren't just binary? For instance, what if we measure patient satisfaction as "Poor," "Fair," or "Good" before and after a new treatment? The McNemar test can't handle this 3x3 table.
This lesson introduces the solution: the Stuart-Maxwell test. Our goal is to understand this test as a direct generalization of McNemar's test for analyzing paired data in larger square contingency tables (k×k, where k > 2). You will learn its core purpose, the hypothesis it tests, and, most importantly, when it is the appropriate tool for your analysis.
1. The Analytical Challenge: Beyond 2x2 Tables
Imagine a study on vision. Researchers record the unaided distance vision grade for both the right and left eye of 7,477 women. The vision grades are categorical: "Highest," "Second," "Third," and "Lowest." The resulting data forms a 4x4 contingency table.

A natural question arises: Is the distribution of vision grades for the right eye the same as for the left eye in this population? In other words, is there an overall difference in vision quality between left and right eyes?
Because we have paired data (two eyes from the same person) and more than two categories, the McNemar test is not applicable. This is precisely the scenario where the Stuart-Maxwell test is needed.
2. The Stuart-Maxwell Test: Testing for Marginal Homogeneity
The Stuart-Maxwell test is an extension of McNemar's test used for paired categorical data where the variable has three or more levels. Its central purpose is to test the hypothesis of marginal homogeneity.
To understand this concept, let's look at the article "Categorical Data Analysis: Fundamentals and Perspective..." which introduces the test.
Categorical Data Analysis: Fundamentals and Perspective ... - JCDR
This article introduces the Stuart-Maxwell test as a direct extension of McNemar's test for situations with more than two categories. It sets up the data layout and provides a clear example.
Please read the section 'Stuart Maxwell McNemar’s Test of Marginal Homogeneity'. Focus on understanding why it's needed (when McNemar's can't be used) and the general data layout shown in '[Table/Fig-4]'.
What is Marginal Homogeneity?
Marginal homogeneity means that the row totals and column totals of a contingency table are equal for each category. In a "before-and-after" context, this translates to:
- The proportion of subjects in Category 1 before is the same as the proportion in Category 1 after.
- The proportion of subjects in Category 2 before is the same as the proportion in Category 2 after.
- ...and so on for all k categories.
Let's formalize this with the clear definitions from the Statkat resource.
Marginal Homogeneity test / Stuart-Maxwell test
The Statkat page on the Marginal Homogeneity / Stuart-Maxwell test provides very clear, formal definitions of the hypotheses being tested.
Read the sections 'Null hypothesis' and 'Alternative hypothesis'. Notice how the null hypothesis states that the population proportions (π) are equal for each category across the two paired groups.
Based on this, the hypotheses for the Stuart-Maxwell test are:
- Null Hypothesis (): There is marginal homogeneity. For each category j, the population proportion in that category is the same for the first measurement as it is for the second measurement ().
- Alternative Hypothesis (): There is no marginal homogeneity. For at least one category, the population proportion has changed between the two measurements ().
In our vision example (LINK), rejecting the null hypothesis would mean that the overall distribution of vision grades for left eyes is significantly different from that of right eyes.
3. The Logic: Generalizing from Discordant Pairs
Recall that the McNemar test focuses exclusively on the discordant pairs (cells b and c in a 2x2 table) to see if the change in one direction is significantly different from the change in the other.
The Stuart-Maxwell test operates on the same principle but generalizes it to the k×k table. It examines the entire set of discordant pairs. In a 3x3 table with cells denoted by (row i, column j), it considers the differences between:
- (changed from category 1 to 2) and (changed from 2 to 1)
- (changed from category 1 to 3) and (changed from 3 to 1)
- (changed from category 2 to 3) and (changed from 3 to 2)
The test statistic combines these differences into a single value. As noted in the Statkat resource, the calculation involves matrix algebra and is best left to statistical software. The key takeaway is the conceptual link: like McNemar, the Stuart-Maxwell test is fundamentally a test of asymmetry in the off-diagonal counts.
The resulting test statistic follows a chi-squared distribution with degrees of freedom, where k is the number of categories.
4. Application and Interpretation
Let's return to the "Categorical Data Analysis" article for a practical example. It examines the effect of an awareness program on smoking status, where the categories are "non-smokers," "1-10 cigarettes per day," and ">10 cigarettes per day."
This creates a 3x3 table ([Table/Fig-5]) showing subjects' smoking habits at baseline and after 3 months. The analysis yielded a significant result: "The Stuart Maxwell McNemar’s test statistic indicates enough evidence to reject the null hypothesis and conclude that the intervention was effective..."
What does this mean?
A significant p-value from the Stuart-Maxwell test tells us that the overall distribution of smoking habits changed. We have rejected the hypothesis that the marginal proportions are the same before and after. This suggests the awareness program had a tangible impact, causing a net shift among the smoking categories.
Important Note: The test itself is an omnibus test. It tells you that a significant change occurred, but not which specific categories changed. For that, you would need to perform post-hoc tests, similar to what you might do after an ANOVA. For now, the focus is on interpreting the main test result.
5. When to Use the Stuart-Maxwell Test
This is a critical part of your functional understanding. The choice of test depends on the structure of your data. The summary table at the end of the "Categorical Data Analysis" article is an excellent guide.
Categorical Data Analysis: Fundamentals and Perspective ... - JCDR
The table at the end of this article provides a concise and powerful summary of when to use McNemar's test versus its generalizations.
Scroll to the very end of the document and study '[Table/Fig-13]: Comparison of tests discussed in the article'. This gives you a clear decision rule.
Based on that table and our discussion, here is a clear decision guide:
| You Should Use... | If Your Data Has... |
|---|---|
| McNemar Test | 2 paired measurements AND a binary (2-level) categorical variable. |
| Stuart-Maxwell Test | 2 paired measurements AND a multi-level (>2 levels) categorical variable. |
| Chi-Square Test | Independent (unpaired) groups, regardless of the number of categories. |
The main assumption, as with McNemar's test, is that the pairs are independent of one another (e.g., one person's change in opinion doesn't influence another's).
Conclusion
In this lesson, you've bridged the gap from binary paired data to multi-level paired data. You now understand the role of the Stuart-Maxwell test as the direct generalization of the McNemar test.
Key Takeaways:
- The Stuart-Maxwell test is used for paired categorical data when there are more than two categories (a k×k table).
- It tests the hypothesis of marginal homogeneity, which states that the overall distribution of responses is the same at both measurement points.
- Conceptually, it extends McNemar's logic by examining the asymmetry across all pairs of discordant (off-diagonal) cells.
- A significant result indicates a net change in the response distribution between the two paired measurements.
Preview of the Next Lesson:
We have now covered scenarios with two measurement points for both binary (McNemar) and multi-level (Stuart-Maxwell) outcomes. But what if you have more than two measurement points? For example, what if you measured whether a patient felt "pain" or "no pain" every week for four weeks? For this, we need yet another tool. In the next lesson, we will explore the Cochran Q test, which is designed for situations with three or more related measurements of a binary outcome.