Atlas
statminds
CategoricalThe underlying model family class (e.g. GLM, linear model, categorical matrix, log-linear).Parametric ReferenceStatistical methods that assume a specific probability distribution family (typically normal).12-stage workflow

Stuart-Maxwell Test of Marginal Homogeneity

Tests marginal homogeneity in k×k paired table; more powerful than Bowker's for detecting marginal differences. Tests whether row and column marginal distributions are equal.

Model familyCategorical
Hypothesisomnibus
AliasesStuart-Maxwell test · marginal homogeneity test · Bhapkar test (improved version)
G1
paired_comparison
1

What is it?

Stuart-Maxwell Test evaluates whether the marginal distributions of a paired KxK contingency table are identical (marginal homogeneity).

2

When to use it

  • Matched Pairs with K > 2 categories: e.g. Pre vs. Post survey answers (Agree, Neutral, Disagree).
  • Overall Margin Test: Evaluates if row sums differ from column sums.
3

Core Idea

We measure whether the total proportion of people answering Category i is equivalent at time point 1 (row margin) and time point 2 (column margin):

Row Margins = Column Margins

Unlike the Bowker test which requires absolute symmetry cell-by-cell, Stuart-Maxwell only requires the overall marginal totals to match.

4

Hypotheses

H0: Marginal proportions are homogeneous: Row totals = Col totals.
Ha: Marginal proportions differ significantly (distribution shift).
5

How it works

  1. Compute the difference vector d between row and column marginals.
  2. Estimate the covariance matrix V using cell frequencies.
  3. Invert V and compute S = d' * V^-1 * d.
  4. Refer S to a chi-square distribution with df = K - 1.
6

Assumptions

📊 Matched Units: Dependent sample pairs.
👤 Large Sample: Counts must be sufficient to estimate the covariances.
7

Effect Size

Expressed as the relative change in category proportions from Pre to Post, showing where concentration shifted.

8

Quick Example

MarginCat 1Cat 2Cat 3
Row Margins757568
Col Margins537293
Interactive Sandbox

Stuart-Maxwell Live Laboratory

Adjust off-diagonal transition values to watch the marginal totals shift and test for marginal homogeneity.

n_12 vs n_2115 vs 5
n_13 vs n_3120 vs 8
n_23 vs n_3225 vs 12
Pre vs. Post marginal distributions (Parallel Coordinates)Connecting lines illustrate category shifts
PrePost
Calculations Output
MetricValue
Total Pairs (N)220
Stuart-Maxwell S-statistic13.1250
Degrees of Freedom (df)2
p-value0.0003
Homogeneity Verdict

Heterogeneous Margins The marginal proportions differ significantly (p = 0.0003). Pre-to-post category shifts display systematic structural trends.

01Hypothesis test logic

Hypotheses

Pragmatic null and alternative hypotheses defined in mathematical notation.

A hypothesis is a question sharpened to a point. Ambiguity is the enemy of inference.
Logic Core
Null · H₀

H₀: Marginal distributions are equal (pᵢ. = p.ᵢ for all i)

Alternative · Hₐ

Hₐ: Marginal distributions differ (pᵢ. ≠ p.ᵢ for at least one i)

Why it matters omnibus

Tests equality of row and column marginal distributions in paired k×k table. For 2×2 tables, reduces to McNemar's test. Uses chi-square distribution with k-1 degrees of freedom. More powerful than Bowker's test for detecting systematic shifts in marginal distributions.

02Model diagnostics

Assumptions

The core mathematical criteria needed to ensure that statistical testing remains unbiased and valid.

Build your analysis on rock, not sand. Verify the mathematical foundation before building the model.
Integrity Shield
6
Assumptions
0
Critical / High Severity
How to check
Quick
Verify study design involves pairing: longitudinal (same subjects over time) or cross-sectional matching (twins, matched controls). Sample size should equal number of pairs, not total measurements.
Rigorous
Confirm each subject/unit has unique pair identifier. For repeated measures: verify each subject appears exactly twice. For matched pairs: verify explicit matching criteria (age, sex, baseline characteristics). Check no unpaired observations exist.
If violated
Cannot retroactively create pairing. If observations are truly independent, fundamental design issue exists. Alternatives: For independent samples: use chi-square test of independence or Fisher's exact test. For unmatched repeated measures: use generalized estimating equations (GEE) or mixed-effects models with appropriate correlation structure.
chi square independencefisher exactgee
How to check
Quick
Verify nrow = ncol and rownames = colnames. Confirm both dimensions use same category labels in same order. Check that diagonal represents agreement (same category both times).
Rigorous
Create contingency table from raw data. Verify: (1) table is square, (2) categories are identically defined across measurements, (3) no missing categories in either dimension, (4) category ordering is consistent if ordinal.
If violated
Harmonize category definitions across measurements. If categories differ, recode to common scale. Subset to overlapping categories if only some categories match. Alternatives: For non-square tables: cannot test marginal homogeneity. Use alternative association measures (Cramér's V) or regression models for different row/column scales.
How to check
Quick
Review sampling: random selection of pairs? No hierarchical structure (pairs nested in clusters)? For longitudinal data, are measurement occasions sufficiently spaced to avoid carryover effects?
Rigorous
Calculate intraclass correlation (ICC) if clustering suspected. For sequential data, compute autocorrelation function (ACF) to detect temporal dependencies. Use design effects to quantify clustering impact on effective sample size.
If violated
Account for clustering using cluster-robust standard errors, design effects, or weighting. Thin time series data to reduce autocorrelation. Use subsampling to achieve independence. Alternatives: For clustered data: generalized estimating equations (GEE) with exchangeable correlation structure. For multilevel data: mixed-effects ordinal regression with random effects for clusters. For time series: time series analysis methods.
gee
How to check
Quick
Calculate row sums and column sums. Verify each marginal total ≥ 10. Count how many categories have marginal < 10.
Rigorous
Compute marginal distributions and assess expected covariance matrix of marginal differences for near-singularity. Check condition number of covariance matrix. Simulate Type I error rate via Monte Carlo to verify nominal α level.
If violated
Combine adjacent or conceptually similar categories to achieve marginal counts ≥ 10. Increase sample size if feasible. Focus on key category contrasts. Alternatives: Use exact conditional tests for small samples (limited software support). Bootstrap p-values via permutation. Use Bhapkar's modification (more robust to small samples than Stuart-Maxwell).
stuart maxwell
How to check
Quick
Identify whether categories have natural ordering (ordinal: mild/moderate/severe) or not (nominal: type A/B/C). Consider whether directional hypotheses exist (e.g., 'scores improved' vs 'scores changed').
Rigorous
Plot marginal distributions at both time points. Assess whether shifts are directional (ordinal pattern) or mixed (nominal pattern). Consider whether research question is about directional change or any change.
If violated
No violation per se - Stuart-Maxwell is valid for both nominal and ordinal. However, may not be most powerful test for ordinal data with directional alternatives. Alternatives: For ordinal data with directional hypotheses: Wilcoxon signed-rank test (tests median shift), sign test, ordinal regression with GEE. For nominal data: Stuart-Maxwell is appropriate. Can supplement Stuart-Maxwell with trend tests if ordinal structure is important.
stuart maxwellwilcoxon signed rankgeesign test
How to check
Quick
Calculate n/k ratio. Ensure n/k ≥ 10. For k=3 categories, n=30 is minimum; n=60+ is better. For k=5 categories, n=50 minimum; n=100+ is better.
Rigorous
Conduct power analysis via simulation: generate data under null (equal marginals) and specific alternative (e.g., 10% shift in one category), test at various sample sizes, determine n for 80% power. Check covariance matrix invertibility at observed n.
If violated
Increase sample size, reduce number of categories by combining similar groups. Prioritize key category distinctions. Alternatives: Use exact McNemar for 2×2 tables. Use Bhapkar test (more stable for small samples than Stuart-Maxwell). Report results as exploratory with power caveats.
mcnemarstuart maxwell
03Residual Forensics

Diagnostics

Checking residual plots and indices to examine model deviations and ensure standard error integrity.

Trust, but verify. The outliers often hold more truth than the averages.
System Health
Essential checks
  1. Verify table is square (k×k) with matching row/column labels
  2. Calculate and compare marginal distributions (row sums vs column sums)
  3. Check marginal frequencies ≥ 10 for all categories
  4. Compute marginal differences (pᵢ. - p.ᵢ) for each category
  5. Verify covariance matrix of marginal differences is non-singular
Recommended checks
  1. Plot marginal distributions side-by-side (time 1 vs time 2)
  2. Visualize marginal differences with confidence intervals
  3. Create paired profile plot showing individual transitions
  4. Compare Stuart-Maxwell with Bowker's test (different hypotheses)
  5. Calculate Bhapkar's V statistic (alternative effect size)
  6. Assess whether marginal shifts are directional (ordinal) or mixed
  7. Bootstrap confidence intervals for marginal differences
  8. Examine cell-level patterns to understand marginal shifts
  9. Plot difference (pᵢ. - p.ᵢ) against average (pᵢ. + p.ᵢ)/2 (Bland-Altman style)
  10. Calculate McNemar tests for specific 2-category contrasts if k > 2
04Live Instances

Applied Minds

Review concrete study examples, data layout guidelines, and copy executable syntax scripts.

Theory is the map. Practice is the terrain. Simulation bridges the gap.
Applied Wisdom
Example 01

3-Category Analysis

Political scientists surveyed 120 voters before and after a campaign on their opinion about a policy (Oppose/Neutral/Support). Stuart-Maxwell test assesses whether the marginal distribution of opinions shifted, indicating whether the campaign had an overall effect on public opinion, regardless of individual-level transitions. This differs from Bowker's test which would assess bidirectional symmetry of changes.

05Tactical Pivots

Alternatives

Structured fallback pathways for choosing alternative tests when normality or slopes requirements fail.

When the path is blocked, pivot. Rigor is not rigidity; it is the intelligent adaptation to reality.
Adaptive Strategy
Measurement Precision Ladder Ideal · Paired Multi-Category Nominal
Ratio
Consider Paired T-Test. Categorical marginal comparison discards the clinical magnitude of internal change.
Data Flattening
Ordinal Pairs
Maintain Stuart-Maxwell. Optimal for auditing if the population 'Grows' or 'Shrinks' across ranked recovery levels.
Peak Signal
Nominal Pairs
Ideal for Multi-Group Status Flips. Ensure the marginal counts are large enough to stabilize the χ² approximation.
Standard Precision
Binary Pairs
Simplify to McNemar's Test—which is the binary specific version of Stuart-Maxwell.
Structural Parity
Temporal Trajectory Audit Longitudinal Profile Snapshot
Paired Profile
Before vs After.
Stay with Stuart-Maxwell. Find if the global categorical profile has significantly shifted.
Trajectory Shifts
3+ stages.
Pivot to Marginal Homogeneity GEE or Multilevel Categorical Modeling.
Adaptive Technical Safeguards · adaptive safeguards
excessive diagonal density
  • McNemar-Exact Strikes — If most participants show zero change, focus only on the 'Switcher' cells to maximize power.
  • Marginal Frequency Audit — Compare observed vs expected marginals to identify the specific category driving the shift.
no directional bias
  • Bowker Symmetry Test — Use the stricter symmetry audit if you need to prove the exact pattern of 'Up-Flips' vs 'Down-Flips'.
06Adjusted Comparisons

Post-hoc

Group mean comparisons and correction controls (e.g. Tukey HSD, Bonferroni) to protect against Family-Wise Error Rates.

The omnibus test opens the door; post-hoc analysis explores the room.
Forensic Detail
Adjusted Comparisons

Post-hoc pairwise tests defined for this model.

Interpretation Guidelines

Stuart-Maxwell is the 'General McNemar'. Use marginal contrasts to find which category provided the clinical breakthrough in your longitudinal grid.

07Standardized scale impact

Effect Size

Understanding effect sizes (e.g., Cohen's d, Partial Eta-Squared) and clinical impact benchmarks.

Significance is noise. Magnitude is the signal. Measure the impact, not just the probability.
Impact Magnitude
formula

V = sqrt(χ²/n)

interpretation

Standardized measure of marginal heterogeneity. Range: 0 (perfect homogeneity) to 1 (maximum heterogeneity).

guidelines

0.1 = small effect, 0.3 = medium effect, 0.5 = large effect

note

Sample-size independent. Analogous to Cohen's w for chi-square tests. Preferred over raw chi-square for effect size.

confidence intervals

Use bootstrap resampling (1000+ iterations) to obtain 95% CI for Bhapkar's V

formula

dᵢ = pᵢ. - p.ᵢ for each category i

interpretation

Raw difference in marginal proportions. Positive values indicate category was more frequent at time 1, negative at time 2.

use

Identifies which specific categories shifted and in which direction

note

Report marginal differences with confidence intervals: dᵢ ± 1.96*SE(dᵢ) where SE computed from covariance matrix

formula

dᵢ / SE(dᵢ)

interpretation

Z-score for each marginal difference. |z| > 1.96 indicates significant shift for that category at α=.05.

note

Useful for identifying which categories drive overall test significance

Recommended Metric: Bhapkar's V with bootstrap 95% CI, plus marginal differences with SE for interpretation
Small
0.2
Medium
0.5
Large
0.8
0.50
Bhapkar's V with bootstrap 95% CI, plus marginal differences with SE for interpretation
Recommended Measure
3
Available Metrics
ReportUse Bhapkar's V with bootstrap 95% CI, plus marginal differences with SE for interpretation to represent clinical impact magnitude.
08Statistical Power

Sample Size

Guidelines for minimum sample requirements and power analysis parameters.

An underpowered study is an ethical failure. Respect the data by collecting enough of it.
Power Protocol
Floor Requirements

The 'Switching Density' Minimum: A minimum of 50 pairs is recommended for a 3x3 table. Stuart-Maxwell math audits the 'Off-Diagonal' cells—if switches are rare, the model lacks authority.

Effect SizeParametersRequired n
Small Effectw=0.10 (Small)n ≈ 1000 pairs
Medium Effectw=0.30 (Medium)n ≈ 120 pairs
Large Effectw=0.50 (Large)n ≈ 45 pairs
Key considerations

The 'Diagonal Penalty': Participants who stay in the same category provide zero information for Stuart-Maxwell. Recruit for 'Change Potential' to ensure your discordant cells are saturated with discovery signal.

G*Power StrategyBenchmark: χ² tests → Stuart-Maxwell (Marginal Homogeneity). Parameters: Row/Column shift, Table Dimension (k x k), α = .05, Power = .80. Note: Power is dictated by the volume of participants who 'Change Categories'.
09APA narrative blueprint

Reporting

How to compile statistical results into publication prose matching APA and journal style guides.

Data does not speak for itself. It requires a translator. Be clear, be precise, be honest.
Narrative Arc
Worked APA paragraph example
The Stuart-Maxwell test assessed whether marginal distributions of policy opinions (Oppose, Neutral, Support) shifted from before to after a political campaign in a paired sample of 120 voters. Marginal frequencies exceeded 10 for all categories at both time points, satisfying the test assumption. The test was significant, χ²(2) = 8.63, p = .013, Bhapkar's V = .268 (95% CI [.142, .396]), indicating a medium-sized shift in opinion distribution. Examination of marginal differences showed that Support increased by 7.5 percentage points (from 33.3% to 40.8%), Oppose decreased by 4.2 percentage points (from 37.5% to 33.3%), and Neutral decreased by 3.3 percentage points (from 29.2% to 25.8%). Bowker's test for symmetry was not significant, χ²(3) = 3.21, p = .361, indicating that while overall opinion distribution shifted toward Support, individual transitions were bidirectionally balanced (e.g., Oppose→Support transitions were comparable to Support→Oppose). Cohen's kappa was .42 (95% CI [.28, .56]), indicating moderate agreement between time points. These findings suggest the campaign was associated with a net increase in Support, driven primarily by shifts from Oppose and Neutral, with approximately 59% of voters maintaining their initial opinion.
Reusable template

The Stuart-Maxwell test of marginal homogeneity was conducted to examine whether the distribution of variable changed from time 1 to time 2 in a paired sample of n = N units. Marginal frequencies ranged from min to max, satisfying the assumption for asymptotic chi-square approximation. The test was significant/not significant, χ²(k-1) = X.XX, p = .XXX, Bhapkar's V = .XX (95% CI .XX, .XX). Examination of marginal differences revealed that category A increased/decreased by X percentage points (from X% to X%), while category B showed direction of change. The Stuart-Maxwell test indicated overall shift/no overall shift in marginal distributions, whereas Bowker's test for symmetry was significant/not significant, χ²(k(k-1)/2) = X.XX, p = .XXX, indicating that transitions were/were not bidirectionally balanced.

10Exhibit Builder

Manuscript Lab

Copy standard summary tables and forensic reporting grids to outline analysis details.

Table 1: Stuart-Maxwell Test for Shift in 3-Category Diagnosis
Pre-TreatmentPost: HealthyPost: MildPost: Severeχ² (SM)dfp
Healthy425124.522< .001
Mild35154
Severe20253
Note. N = 150 subjects measured twice. Categories: Healthy, Mild, Severe.
p < .001Confirms 'Golden Migration'. The population distribution across the 3 categories has shifted significantly toward 'Healthy' post-treatment.
Header glossary

The Multi-Category Switch Audit. Tests if the overall proportions in Healthy/Mild/Severe shifted significantly from Pre to Post.

The core assumption that the row totals equal the column totals. If rejected (p < .05), a systematic shift has occurred.

11Algorithmic Logic

Command Center

Syntax libraries and function parameters for executing calculations in stats packages.

Code is the modern laboratory. Clean execution ensures reproducible discovery.
Execution Engine
# 1. Execute Stuart-Maxwell Test
DescTools::StuartMaxwellTest(table(df$pre, df$post))

# 2. Extract Bhapkar's Test (More powerful alternative)
DescTools::BhapkarTest(table(df$pre, df$post))
Library stack
R
DescToolscoin
Python
statsmodels.stats.contingency_tables
Elite Forensic Strike

Stuart-Maxwell is the 'General McNemar'. It audits the whole table for symmetry. If significant, use pairwise McNemar tests to find exactly which categories are swapping.

# Perform Post-hoc Pairwise McNemar comparisons
# (Internal audit of switchers)
12The Over-adjustment Trap

Common Mistakes

Analytical caveats and corrections to maintain modeling integrity.

Wisdom is learning from the failures of others. Anticipate the error before it occurs.
Defensive Logic
Why it's wrong
Most common error: treating these as equivalent or interchangeable. Stuart-Maxwell tests marginal homogeneity (H₀: row totals = column totals), while Bowker tests symmetry (H₀: each cell (i,j) = cell (j,i)). They test fundamentally different aspects of the data and can yield different results. A table can have equal marginals but be asymmetric, or have unequal marginals but be symmetric.
The correction
Clarify research question: (1) 'Did the overall distribution shift?' → Stuart-Maxwell. (2) 'Are transitions bidirectionally balanced?' → Bowker. Report both when appropriate, as they provide complementary information. Example: 'Stuart-Maxwell (p=.01) showed marginal shift, but Bowker (p=.35) found symmetric transitions, indicating balanced bidirectional movement with net directional change.'
Why it's wrong
Stuart-Maxwell requires paired/matched observations (same subject at two time points, or matched pairs). Using unpaired data violates the fundamental dependence structure. Chi-square test of independence is for unpaired data and tests association, not marginal homogeneity. Applying Stuart-Maxwell to unpaired data produces invalid p-values and wrong conclusions.
The correction
Verify pairing: each observation should have clear link to its pair (time 1 ↔ time 2 for same subject). If samples are independent (different subjects at time 1 vs time 2), use chi-square test of independence instead. Document pairing mechanism clearly in methods. For repeated measures on different subjects, consider GEE or mixed models.
Why it's wrong
Stuart-Maxwell is omnibus - significant p-value indicates some marginal difference exists but doesn't specify which categories shifted or in which direction. Stopping at p < .05 without examining marginal differences misses the substantive interpretation. Example: 'Opinions changed significantly (p=.02)' is uninformative without specifying direction.
The correction
Calculate and report marginal differences (pᵢ. - p.ᵢ) with standard errors for each category. Identify categories with largest shifts and report direction. Example: 'Marginal homogeneity test was significant (χ²(2)=8.6, p=.01). Support increased by 7.5 percentage points (p=.04), while Oppose decreased by 4.2 points (p=.08), indicating net shift toward favorable opinions.'
Why it's wrong
Unlike Bowker's test which focuses on off-diagonal pairs, Stuart-Maxwell requires adequate marginal totals (row and column sums) for valid chi-square approximation. Marginal counts < 10 can lead to unstable covariance matrix estimation and inflated Type I error. Software may still compute results without warnings.
The correction
Check row and column sums before testing. If any marginal < 10, combine adjacent categories or increase sample size. Report: 'Marginal frequencies ranged from 28 to 47, satisfying the adequacy criterion.' For small samples with sparse marginals, use exact methods or bootstrap p-values.
Why it's wrong
Stuart-Maxwell tests marginal distributions (population-level), not individual transitions. Significant result means overall distribution shifted, but doesn't indicate magnitude of individual-level change. Can have large individual changes with no marginal shift (balanced bidirectional movement), or small individual changes with significant marginal shift (unidirectional movement).
The correction
Supplement Stuart-Maxwell with descriptive statistics on individual change: percentage staying in same category (diagonal), percentage moving up/down. Report both: 'Stuart-Maxwell test showed significant marginal shift (p=.02), with 41% of individuals changing categories, though net effect was concentrated in Support category (+7.5 points).'
Why it's wrong
Stuart-Maxwell treats categories as nominal (unordered), which is valid but may not be most powerful for ordinal data (mild/moderate/severe). For ordinal categories with directional hypotheses (e.g., 'symptoms improved'), ordinal tests like Wilcoxon signed-rank have better power to detect systematic directional shifts.
The correction
For ordinal categories with directional alternatives, consider: (1) Stuart-Maxwell for omnibus test of any marginal shift (nominal approach), plus (2) Wilcoxon signed-rank or sign test for directional alternative (ordinal approach). Report both: 'Stuart-Maxwell test (p=.06) showed marginal trend, while Wilcoxon signed-rank test (p=.02) detected significant upward shift, indicating ordinal structure captures effect better.'
Why it's wrong
Marginal homogeneity (equal row/column sums) is distinct from agreement (diagonal cells). Can have perfect marginal homogeneity with poor agreement (many changes but balanced), or good agreement with marginal heterogeneity (few changes but unidirectional). Stuart-Maxwell tests former, not latter.
The correction
Report both marginal homogeneity (Stuart-Maxwell) and agreement (Cohen's kappa). Example: 'Stuart-Maxwell test was non-significant (p=.42), indicating marginal homogeneity, but Cohen's kappa was low (.28), indicating poor agreement. This pattern suggests balanced bidirectional changes: overall distribution unchanged but individual-level instability.'
Why it's wrong
Stuart-Maxwell requires inverting covariance matrix S of marginal differences. If S is singular or near-singular (determinant ≈ 0), inversion fails or is numerically unstable, producing unreliable test statistics. This occurs with certain data patterns (e.g., empty cells, extreme imbalances) but software may not warn.
The correction
Before testing, check condition number of S matrix: cond(S) = max(eigenvalue) / min(eigenvalue). If cond(S) > 1000, matrix is ill-conditioned. Use pseudo-inverse (Moore-Penrose) instead of direct inverse, or consider Bhapkar's modification which is more numerically stable. Report: 'Covariance matrix was well-conditioned (condition number = 23.4), supporting reliable inference.'
13Academic Lineage

References

Scholarly lineage and citation keys grounding the statistical framework.

We stand on the shoulders of giants. Honor the source of the method.
Academic Lineage
[1]
[2]
[3]
[4]
[5]
[6]
statminds · Stuart-MaxwellMind reference · v2.2 · updated 2026-01-1715 of 15 sections