Atlas
statminds
Categorical TrendThe 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

Mantel-Haenszel Test of Trend

Test for linear trend in proportions across ordered categories (e.g., dose-response); more powerful than chi-square when trend exists..

Model familyCategorical Trend
Hypothesistwo-tailed (or one-tailed: increasing/decreasing)
AliasesLinear-by-linear association test · Mantel extension
G1
association
G2
description
1

What is it?

Mantel-Haenszel Trend Test (Linear-by-Linear Association) measures linear relationship strength between two ordinal variables.

2

When to use it

  • Two Ordinal Factors: e.g. Customer Satisfaction (1-5) vs. Loyalty Tier (1-3).
  • Trend Direction Focus: Checks if one ordinal increases as the other increases.
3

Core Idea

We calculate the Pearson correlation coefficient r between the assigned ordinal categories, and test if it is significantly non-zero:

X2_MH = (N - 1) * r2

This statistic focuses all power onto a linear relationship, bypassing the general independence test's multi-df noise.

4

Hypotheses

H0: No linear association exists between the two ordinal variables (r = 0).
Ha: There is a significant linear association (r != 0).
5

How it works

  1. Assign scores to both dimensions of cross-classification.
  2. Compute the Pearson correlation coefficient r.
  3. Multiply (N-1) by r^2 to get X2_MH.
  4. Test against chi-square distribution with df = 1.
6

Assumptions

📊 Ordinal Scaling: Both factors must have meaningful linear ordering.
👤 Independence: Mutually exclusive categorical sorting.
7

Note

This test is mathematically identical to checking the significance of the linear regression slope between row and column scores.

8

Quick Example

Satisfaction \ TierTier 1Tier 2Tier 3
Satisfied101535
Neutral121815
Dissatisfied25105
Interactive Sandbox

Mantel-Haenszel Live Laboratory

Vary the correlation strength and sample size N to watch cell concentration shift in the ordinal association grid.

Correlation coefficient (r)0.35
Sample Size (N)100
3x3 Ordinal cross-classification concentration gridPositive r concentrates cells along diagonal; negative along anti-diagonal
HighMedLowHighMedLow
Calculations Output
MetricValue
Sample Size (N)100
Mantel-Haenszel X2 (X2_MH)12.1275
Degrees of Freedom (df)1
p-value0.0005
Association Verdict

Significant Association There is a significant linear association between the two ordinal variables (p = 0.0005).

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₀: No linear trend in proportions across ordered categories

Alternative · Hₐ

Hₐ: Linear trend exists (increasing or decreasing proportions)

Why it matters two-tailed (or one-tailed: increasing/decreasing)

Tests whether binary outcome proportions change linearly with ordered exposure levels. Mathematically equivalent to Cochran-Armitage trend test.

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
Verify logical progression of categories. Ensure ordering reflects increasing/decreasing intensity, dose, or severity.
If violated
If categories lack natural order, use standard chi-square test of independence. If ordering unclear, consider multiple orderings in sensitivity analysis.
How to check
Plot observed proportions vs. exposure scores. Assess visual linearity. Consider polynomial contrasts or spline fits to detect non-linearity.
If violated
If non-linear: use logistic regression with polynomial terms, categorical analysis without linearity assumption, or stratified analysis.
How to check
Review study design for dependencies: longitudinal data, family clusters, geographic clustering, nested structures (patients within clinics).
If violated
For correlated data, use generalized estimating equations (GEE), mixed-effects logistic regression, or conditional logistic regression for matched data.
How to check
Calculate expected frequencies: E_ij = (n_i+ × n_+j) / n. Count cells with E_ij < 5. Check if sample is balanced across exposure levels.
If violated
Combine adjacent exposure categories, increase total sample size, use exact permutation tests, or ensure at least 10-15 observations per exposure level.
How to check
Consider whether equal spacing is reasonable. For dose-response, use actual dose values. For ordinal scales without natural metric, equal spacing may be acceptable.
If violated
Use actual exposure values when available (mg dose, years education, BMI categories' midpoints). Compare results with different scoring schemes.
How to check
Confirm outcome has exactly two categories. If outcome is ordinal (e.g., none/mild/severe), consider whether dichotomizing is appropriate.
If violated
For ordinal outcomes: use ordinal logistic regression (proportional odds model). For multinomial: use multinomial logit. For continuous: use linear regression with ordinal predictor.
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. Plot proportions vs. ordered categories
  2. Check for linear pattern
  3. Calculate expected frequencies (all cells ≥5)
  4. Examine residuals for systematic deviations from linearity
Recommended checks
  1. Sensitivity analysis: compare results with different score assignments
  2. Test for departure from linearity (compare MH trend vs. general chi-square)
  3. Assess influence of extreme categories or outliers
  4. Compare MH trend test with standard chi-square (if similar p-values, linearity assumption may not hold)
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

Air Pollution and Respiratory Disease

Epidemiological study examining whether respiratory disease prevalence increases with residential proximity to industrial pollution source. Four exposure zones based on distance.

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 · Stratified 2x2 Nominal
Ratio
Consider Multiple Regression. Stratifying continuous data creates 'Information Leaks' and artificial boundaries.
Logic Collapse
Binary x Binary
Maintain Mantel-Haenszel logic. The definitive engine for auditing associations while neutralizing a single confounder.
Peak Signal
Multi-Nominal
Pivot to Log-Linear Analysis to model higher-order interactions in larger stratified grids.
Threshold Loss
Temporal Trajectory Audit Stratified Snapshot
Static Layers
Single point purified.
Stay with Mantel-Haenszel. Strip away confounding noise mathematically.
Repeated Layers
Trajectory purity.
Pivot to GEE or Multilevel Logistic to control for confounders while auditing longitudinal change.
Adaptive Technical Safeguards · adaptive safeguards
heterogeneity of odds
  • Logistic Regression Interaction — If the effect reverses across strata (Simpson's Paradox), you must model the interaction, not the pooled average.
  • Breslow-Day Strike — Audit if the Odds Ratios are consistent enough to justify the Mantel-Haenszel summary.
too many confounders
  • Multiple Logistic Regression — The elite path when you need to control for more than 1 or 2 categorical layers.
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
  • Test homogeneity of odds ratios across strata (Breslow-Day test)
  • Compare with Woolf's test for homogeneity
  • Examine stratum-specific odds ratios for effect modification
  • Calculate Mantel-Haenszel common odds ratio with CI
  • Compare with logistic regression controlling for stratifying variable
Interpretation Guidelines

Mantel-Haenszel tests association across strata. Traditional post-hoc tests are not applicable.

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
calculation

OR = exp(β) from logistic regression with score as predictor

interpretation

Multiplicative increase in odds for each unit increase in exposure score

example

OR = 1.30 per category means 30% increase in odds for each exposure level increase

recommended

Most clinically interpretable effect size

calculation

Logistic regression coefficient for score variable

interpretation

Change in log-odds per unit score increase

note

Exponentiate to obtain odds ratio

calculation

Difference in proportions: highest vs. lowest exposure category

interpretation

Percentage point increase across exposure range

clinical use

Calculate NNT (number needed to treat) = 1 / ARD

calculation

Pearson correlation between category scores and proportions

interpretation

Strength of linear relationship (r close to ±1 indicates strong trend)

limitation

Ignores sample sizes; not typically reported

Recommended Metric: Odds ratio per unit score increase
Small
0.2
Medium
0.5
Large
0.8
0.50
Odds ratio per unit score increase
Recommended Measure
4
Available Metrics
ReportUse Odds ratio per unit score increase 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 'Stratified Depth' Mandate: A minimum of 10 participants per stratum (cell) is essential. Mantel-Haenszel audits trends across layers—if layers are empty, the pooled discovery basis collapses.

Effect SizeParametersRequired n
Small EffectOR = 1.5 (Small)n ≈ 600 total
Medium EffectOR = 2.5 (Medium)n ≈ 110 total
Large EffectOR = 4.0 (Large)n ≈ 45 total
Key considerations

The 'Homogeneity Tax': If the trend is significant in Layer 1 but reverses in Layer 2, the Mantel-Haenszel strike will yield zero power. Audit the 'Breslow-Day' test before trusting the pooled N.

G*Power StrategyBenchmark: χ² tests → Mantel-Haenszel (Stratified Trend). Parameters: Odds Ratio (OR), Number of strata, α = .05, Power = .80. Note: Power depends on the consistency of the trend across all strata.
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
A Mantel-Haenszel trend test was performed to assess the linear relationship between residential proximity to an industrial pollution source and respiratory disease prevalence among 800 residents across four exposure zones. Distance scores were assigned based on zone midpoints (>10km = 12.5, 5-10km = 7.5, 2-5km = 3.5, <2km = 1.0). Expected cell frequencies ranged from 37.5 to 103.1, satisfying the minimum frequency assumption. The analysis revealed a highly significant linear trend (χ²_MH = 52.18, df = 1, p < .001), with disease prevalence increasing systematically from 22.5% in the furthest zone to 57.5% in the nearest zone. Each 1-km decrease in distance from the pollution source was associated with a 1.14-fold increase in respiratory disease odds (95% CI: 1.10-1.18). The linear trend model was adequate, showing no significant departure from linearity (χ²_departure = 0.33, df = 2, p = .85). These findings demonstrate a clear dose-response gradient supporting an association between pollution exposure and respiratory disease risk.
Reusable template

A Mantel-Haenszel trend test revealed a significant linear association between exposure and outcome (χ²_MH = X.XX, df = 1, p = .XXX). The odds ratio was X.XX (95% CI: X.XX-X.XX) per unit increase in exposure score, indicating a dose-response relationship. The linear trend model was adequate, with no significant departure from linearity (χ²_departure = X.XX, df = k-2, p = .XXX).

10Exhibit Builder

Manuscript Lab

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

Table 1: Mantel-Haenszel Chi-Square for Linear Trend
Exposure LevelDisease Rate (%)M-H χ² (Trend)dfp-valueCommon Odds Ratio
Low12.5%24.521< .0012.15
Medium28.4%(per step)
High45.2%
Note. N = 400. Stratified by Center. Exposure: Low < Med < High. Outcome: Disease (Yes/No).
p < .001Confirms 'Dose-Response'. The risk of disease is not just different between groups; it rises systematically as exposure increases.
Header glossary

The Linear Detector. Tests specifically for a linear increase (or decrease) in risk across ordinal categories, controlling for the stratification factor (Center).

The Gradient. Estimate of how much the odds of disease increase for each single-step increase in exposure level (e.g. Low to Med).

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 Mantel-Haenszel Trend Test
mantelhaen.test(table(df$center, df$exposure, df$outcome))

# 2. Visualize Trend across Strata
cotabplot(table(df$center, df$exposure, df$outcome))
Library stack
R
statsvcd
Python
statsmodels.stats.contingency_tables
Elite Forensic Strike

M-H assumes the trend is consistent across all strata (Homogeneity of Odds Ratios). If the Woolf test fails, the M-H estimate is invalid because the trend depends on the stratum (Interaction).

# Execute Woolf Test for Homogeneity
woolf_test(table_data)
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
Equal spacing (0,1,2,3...) assumes uniform intervals between categories, which may not reflect true exposure differences. For example, pollution zones at distances <2km, 2-5km, 5-10km, >10km have unequal spacing. Using (0,1,2,3) instead of midpoints (1, 3.5, 7.5, 12.5) distorts dose-response relationship and can attenuate effect estimates by 40-60%.
The correction
Use actual exposure values when available (dose amounts, years, concentration levels, distance in km). Example: For BMI categories 18-25, 25-30, 30-35, >35, use midpoints (21.5, 27.5, 32.5, 37.5). For truly ordinal scales without natural metric (e.g., 'mild/moderate/severe'), equal spacing is acceptable but conduct sensitivity analysis with alternative scoring schemes.
Why it's wrong
Large samples can yield highly significant p-values (p < .001) for trivial trends that lack clinical meaning. Test statistic increases with n regardless of effect magnitude. Example: OR=1.05 per category may be 'significant' with n=50,000 but represents only 5% odds increase, clinically negligible.
The correction
Always report effect sizes (OR, absolute risk difference) alongside p-values. Assess whether observed trend is clinically meaningful, not just statistically significant. Report: 'Significant trend (p<.001) with OR=1.05 per category (95% CI: 1.03-1.07), representing small but consistent effect.' Discuss clinical relevance: 'This translates to 5% increased odds per exposure level, which accumulates to 22% increase across full exposure range.'
Why it's wrong
Small expected frequencies (< 5) in sparse cells inflate Type I error rates to 8-15% (vs. nominal 5%) and compromise test validity. Chi-square approximation breaks down with sparse data, producing unreliable p-values that may falsely indicate significance.
The correction
Check ALL cells' expected frequencies: E_ij = (n_i+ × n_+j) / n. If any < 5, combine sparse adjacent categories (e.g., merge '<2km' with '2-5km' zone), increase sample size, or use exact permutation tests for small samples (coin package in R: independence_test() with distribution='exact').
Why it's wrong
Blindly applying trend test without checking whether proportions actually follow linear pattern. Non-linear trends (U-shaped, J-shaped, threshold effects, plateau) violate linearity assumption and severely reduce power (40-70% power loss). Test may miss important non-monotonic relationships.
The correction
ALWAYS plot observed proportions vs. exposure scores before analysis. Assess linearity visually (points approximate straight line?) and statistically using departure test: χ²_departure = χ²_general - χ²_trend with df = k-2. If p_departure < .05, use non-linear models (logistic regression with polynomial terms, splines, or categorical treatment without linearity constraint).
Why it's wrong
MH trend test requires ordinal exposure variable with meaningful progression. Using with nominal categories (e.g., different treatment types A, B, C with no inherent ordering, ethnic groups, geographic regions) is statistically invalid and produces uninterpretable results. The 'trend' has no meaning without order.
The correction
Confirm categories have natural ordering (never→former→current smoker, BMI categories, disease severity stages). For nominal variables with no inherent ordering, use standard chi-square test of independence (k-1 df, no trend assumption) or Fisher's exact test for small samples.
Why it's wrong
Simply stating 'significant trend exists' (p=.002) without indicating whether outcome increases or decreases with exposure, or quantifying strength, provides no actionable information for clinical or policy decisions. Readers cannot assess practical relevance or compare across studies.
The correction
Report direction (positive/negative/increasing/decreasing trend), magnitude (OR with 95% CI), and substantive interpretation. Example: 'Respiratory disease prevalence increased significantly with residential proximity to pollution (χ²_MH=52.2, p<.001). OR=1.14 per km closer (95% CI: 1.10-1.18), meaning 14% higher odds for each kilometer closer to source, accumulating to 2.8-fold increase from furthest (>10km) to nearest (<2km) zone.'
Why it's wrong
Observed trends may reflect confounding variables (age, SES, comorbidities, lifestyle factors) rather than causal exposure effects. MH trend test does not adjust for covariates. Example: proximity-disease association may be confounded by SES if poorer neighborhoods are closer to pollution sources.
The correction
Use multivariable logistic regression to adjust for identified confounders: glm(outcome ~ exposure_score + age + sex + SES + comorbidities, family=binomial). MH test is appropriate for unadjusted bivariate screening, but adjusted analysis required for causal inference. Report both unadjusted and adjusted estimates: 'Unadjusted OR=1.14 (p<.001); adjusted OR=1.09 (p=.002) after controlling for age, sex, and SES, suggesting partial but not complete confounding.'
Why it's wrong
Mantel-Haenszel name applies to two different tests: (1) MH trend test (linear association in 2×k table, this test), and (2) MH stratified test (common odds ratio across strata, different test). Confusion leads to incorrect application and interpretation, especially regarding stratification vs. trend analysis.
The correction
Clarify which MH test you're using. MH TREND test: tests linear association between ordered exposure and binary outcome (unstratified, 1 df). MH STRATIFIED test: estimates common OR across multiple strata adjusting for confounding (Mantel-Haenszel common OR). If you need to test trend WHILE controlling for strata, use Cochran-Mantel-Haenszel test or stratified logistic regression.
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]
statminds · Mantel-HaenszelMind reference · v2.2 · updated 2026-01-1715 of 15 sections