WooldridgeDiD: outcome-fit hint for OLS on binary/count outcomes by igerber · Pull Request #513 · igerber/diff-diff · GitHub
Skip to content

WooldridgeDiD: outcome-fit hint for OLS on binary/count outcomes#513

Merged
igerber merged 1 commit into
mainfrom
feature/wooldridge-efficiency-hint
Jun 1, 2026
Merged

WooldridgeDiD: outcome-fit hint for OLS on binary/count outcomes#513
igerber merged 1 commit into
mainfrom
feature/wooldridge-efficiency-hint

Conversation

@igerber

@igerber igerber commented May 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a non-fatal UserWarning (fit-time gate 0g, OLS-only) to WooldridgeDiD.fit() when method="ols" is used on a binary ({0, 1}) or non-negative integer-count outcome, noting that a matching nonlinear model (logit / Poisson) is often the more appropriate specification for such outcomes.
  • Framing is paper-faithful (Wooldridge 2023): the nonlinear paths impose parallel trends on the link/index scale (Index-PT) rather than in levels (Linear-PT, which the paper notes is "only valid for continuous/unbounded outcomes"), and the paper's Section 5 simulations show the linear model both biased and less precise where the nonlinear mean holds. It is a different identifying assumption — a recommended comparison, not an automatic switch or a free efficiency upgrade. OLS remains a valid QMLE for any response (Table 1).
  • Pure, non-fatal detector _suggest_nonlinear_method (binary → logit; non-negative count with >2 distinct → poisson; fractional / continuous / negative / non-numeric → None). Advisory only — it never alters the ATT/SE/inference paths and never raises.
  • Detection reads the full outcome column; _filter_sample is row-preserving (the control group is expressed via the design matrix, not by dropping rows), so the full column and the estimation sample always share the same outcome support (pinned by a regression test).
  • Retires the WooldridgeDiD efficiency-hint Tier A + Methodology/Correctness rows in TODO.md (Feature/wooldridge did #216), migrating the corrected-framing provenance (PR Wave 3 estimator observability: HonestDiD M=0 test, Wooldridge canonical-link warning, ARP vertex diagnostic #453 R1) into the REGISTRY note.

Methodology references (required if estimator / math changes)

  • Method name(s): WooldridgeDiD (ETWFE) — advisory outcome-fit hint only; no change to estimation or inference.
  • Paper / source link(s): Wooldridge, J. M. (2023), "Simple approaches to nonlinear difference-in-differences with panel data," The Econometrics Journal 26(3), C31–C66 — Table 1 (canonical link / LEF pairings), Eq. 2.5 (Linear PT) vs Eq. 2.6–2.7 (Index PT), Section 5 (simulations). Reconciled against docs/methodology/papers/wooldridge-2023-review.md.
  • Any intentional deviations from the source (and why): None (advisory warning, no estimand change). Documented design choices in docs/methodology/REGISTRY.md §WooldridgeDiD "Nonlinear extensions": detection is a high-signal heuristic (binary {0,1}; non-negative integer count with >2 distinct → Poisson) that does not separate bounded binomial from unbounded counts or detect fractional outcomes — that would require user-supplied outcome-family metadata.

Validation

  • Tests added/updated: tests/test_wooldridge.py — new TestOutcomeFitHint (detector unit cases incl. bool dtype / bounded-support / non-numeric; binary → logit and count → poisson emission; continuous + logit silence; cohort_trends smoke; warnings.filterwarnings suppression; paper-faithful framing guard; and a _filter_sample row-preserving invariant). Full tests/test_wooldridge.py passes.
  • Backtest / simulation / notebook evidence (if applicable): N/A (advisory warning; tutorial 16's OLS fits use continuous outcomes, so the hint does not fire there).

Security / privacy

  • Confirm no secrets/PII in this PR: Yes

Generated with Claude Code

@github-actions

Copy link
Copy Markdown

@igerber igerber added the ready-for-ci Triggers CI test workflows label May 31, 2026
Add a non-fatal UserWarning when WooldridgeDiD(method="ols") is used on a
binary ({0,1}) or non-negative integer-count outcome. Following Wooldridge
(2023), the warning notes that a matching nonlinear model (logit / Poisson)
is often the MORE APPROPRIATE specification for such outcomes: it imposes
parallel trends on the link/index scale rather than in levels (level-PT is
only valid for continuous/unbounded outcomes), and the paper's Section 5
simulations show the linear model both biased and less precise where the
nonlinear mean holds. It is a different identifying assumption than linear
OLS -- which fits depends on which parallel-trends restriction holds -- so
the hint is a recommended comparison, not an automatic switch or a free
efficiency upgrade. OLS remains a valid QMLE for any response (Table 1).

- _suggest_nonlinear_method: pure, non-fatal detector (binary -> logit,
  non-negative count with >2 distinct -> poisson; fractional/continuous/
  negative/non-numeric -> None). Bounded binomial-style integers are not
  separately distinguished from unbounded counts (documented heuristic).
- fit() gate 0g (OLS-only, stacklevel=2) emits the hint on the full
  outcome column before sample filtering; never alters the fit or raises
- TestOutcomeFitHint: detector units (incl. the bounded-support case) +
  gate behavior + suppression + paper-faithful framing guard
  (more-appropriate / biased / different assumption / recommended-comparison)
- Docs: REGISTRY Note (LPT-vs-IPT + Section 5 evidence + two-sided framing
  provenance), method docstring, llms-full.txt, wooldridge_etwfe.rst, CHANGELOG
- TODO: remove the Tier A + Methodology/Correctness rows (#216)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@igerber igerber force-pushed the feature/wooldridge-efficiency-hint branch from 4b3215a to a214168 Compare May 31, 2026 22:48
@github-actions

Copy link
Copy Markdown

@igerber igerber merged commit 7506221 into main Jun 1, 2026
26 checks passed
@igerber igerber deleted the feature/wooldridge-efficiency-hint branch June 1, 2026 00:23
@igerber igerber mentioned this pull request Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ci Triggers CI test workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant