Skip to content

EProportions · Guide test 071

Woolf homogeneity test

Uses estimated log odds ratios and variances to test their equality across strata.

Runs in CodeSplashPython (calls R) example not runR example not run

Do it in CodeSplash

In the app, set it up in Analyze with this method:

In Cochran–Mantel–Haenszel test (stratified 2 × 2), choose Homogeneity test = Woolf.

Do it in CodeSplash Run this test on your own data, in Python or R.

Bench

Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.

Bench · Woolf homogeneity test

60
0.60
0.80
0.050

Your data

Edit the counts
EventNo eventTotal
Stratum 1: exposed
16E = 29.0
44E = 31.0
60
Stratum 1: unexposed
13E = 29.0
47E = 31.0
60
Stratum 2: exposed
37E = 29.0
23E = 31.0
60
Stratum 2: unexposed
23E = 29.0
37E = 31.0
60
Stratum 3: exposed
54E = 29.0
6E = 31.0
60
Stratum 3: unexposed
31E = 29.0
29E = 31.0
60
Total174186360

E is the count expected if rows and columns were unrelated.

If H₀ were true

χ² = 7.97
  1. The reference: how χ² varies across samples when H₀ is true.
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .019).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

χW2=∑kwk(ln⁡OR^k−ln⁡OR‾)2,wk=(1a+1b+1c+1d)−1\chi^2_W = \sum_k w_k\left(\ln\widehat{OR}_k-\overline{\ln OR}\right)^2,\qquad w_k = \left(\tfrac1a+\tfrac1b+\tfrac1c+\tfrac1d\right)^{-1}

With your numbers

χW2=7.97,ν=2\chi^2_W = 7.97,\quad \nu = 2
OR^k\widehat{OR}_k
stratum odds ratio
wkw_k
inverse variance of its log

The verdict

χ²(2) = 7.97, p = .019

p ≤ α = .050: reject H₀

Simple and transparent, but unstable with small cells (½ is added when any cell is zero); Breslow–Day is preferred.

Statistic
7.965
p-value
0.0186
Woolf homogeneity test on a 6 × 2 table of 360 counts: χ²(2) = 7.97, p = .019. The p-value is below α = .050, so the data are hard to reconcile with H0.

Woolf homogeneity test on a 6 × 2 table of 360 counts: χ²(2) = 7.97, p = .019. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: stratum log odds ratios are equal.

Assumptions

Independent strata with sufficiently large nonzero cells for normal log odds ratio approximations.

Formula

ys=log⁡asdsbscsws=(1/as+1/bs+1/cs+1/ds)−1Q=∑sws(ys−yˉw)2\begin{gathered}y_s=\log\frac{a_sd_s}{b_sc_s}\\[5pt] w_s=(1/a_s+1/b_s+1/c_s+1/d_s)^{-1}\\[5pt] Q=\sum_sw_s(y_s-\bar y_w)^2\end{gathered}

Parameters and notation

ȳw=Σwsy_s/Σws; S strata.

Structure of the method

Compute each stratum log odds ratio and its approximate inverse variance, form the precision-weighted common log effect, and sum weighted squared deviations from that mean. The chi-square heterogeneity reference has S-1 degrees of freedom under regular large-cell conditions.

Estimated and nuisance parameters

Estimated quantities are four-cell log odds ratios, reciprocal-cell variance estimates, and their weighted mean. Weights are random because they depend on observed cells. Sample sizes and stratum definitions are design quantities; the common log odds ratio is fitted under the null.

Settings and design choices

Fix the strata, effect orientation, and any zero-cell correction before comparing results. State whether a correction is added to every cell or only affected tables. Different corrections can change both each effect and its weight, especially in small studies.

Fitting and adaptation

New observations require recomputing effects, weights, and the weighted mean. A null bootstrap must regenerate whole strata under a shared odds ratio and refit weights rather than treating observed weights as immutable. Classical refitting, not neural fine-tuning, describes this adaptation.

Sensitivity and robustness

A single sparse cell can dominate the approximation or force an arbitrary correction. Large differences with imprecise estimates can produce weak evidence, while many precise strata can detect minor heterogeneity. This is a homogeneity test; it does not test whether the pooled odds ratio equals one.

How to use and calibrate

Use χ²S−1 approximately. If continuity corrections are used, disclose their amount and scope.

Example application

Assess odds ratio heterogeneity across several 2×2 studies.

Interpretation and pitfalls

Watch out

Arbitrary zero-cell corrections can materially alter results. This is a heterogeneity test, not a test of pooled association.

What changed in edition 2

  • New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.

Python and R

Three independent 2×2 strata; maintain the same category ordering in every stratum. Homogeneity tests assess whether a common odds ratio is tenable.

Python · invokes R

Not run — Python launcher syntax checked; R backend runtime not verified · needs Python standard library + Rscript; R packages: DescTools

# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
    raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
tab <- array(c(18,9,12,21,15,7,15,23,20,12,10,18),dim=c(2,2,3))
print(DescTools::WoolfTest(tab))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
                        text=True, capture_output=True)
print(result.stdout)
if result.stderr:
    print(result.stderr)
result.check_returncode()
R

Not run — Syntax checked; runtime not verified in the final environment · needs DescTools

tab <- array(c(18,9,12,21,15,7,15,23,20,12,10,18),dim=c(2,2,3))
print(DescTools::WoolfTest(tab))

Sources

Statistics guide v4 (historical):
Python: Python launcher syntax checked; R backend runtime not verified · R: Syntax checked; runtime not verified in the final environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 071, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT071.