Repository navigation
Add experimental native ChainedDiD for incomplete panels - #887
shawcharles wants to merge 3 commits into
Conversation
…anels Context: - Extend diff-diff to overlapping incomplete panels using within-unit changes, with a paper-derived algorithm and cdid as an external validation reference. Changes: - Add ChainedDiD and ChainedDiDResults with normalised pair IPW, never-treated controls, PT-post and fixed identity GMM; support static complete covariates. - Preserve original-unit accounting and provide analytical unit/cluster covariance, canonical aggregation, constituent weights and support diagnostics. - Add API/LLM documentation, executable tutorial, public exports, plotting integration, algebraic/reference tests and source-bound simulation evidence. - Retain failed coverage qualification and the known continuous-covariate R criterion difference. Sparse-pair pointwise intervals remain experimental. - Record the subsequent user-supplied numerical review; keep maintainer inference-policy and propensity-criterion decisions explicit before merge. - Exclude OR/DR, attrition correction, survey designs, optimal GMM, bootstrap and simultaneous bands. Preserve upstream 4.0.0 release metadata and dependencies. Verification: - Clean upstream contribution: default non-slow pytest suite, 15,619 passed and 291 skipped on CPython 3.14 with the local OpenBLAS backend available. - Focused estimator/reference/integration checks: 609 passed. - Minimum-version/reference checks: 111 passed each on Python 3.9 and 3.15. - Built and installed a local CPython 3.14 Linux/OpenBLAS wheel; isolated Python and Rust consumers agree exactly across four configurations, including aggregation, pickle and plotting checks. - Tutorial 34 executed; Sphinx with -W, Black and Ruff passed. - Independent submission review found no actionable packaging findings. - Subsequent user-supplied numerical review confirmed the bounded fixes but retained sparse-pair undercoverage and requested explicit merge decisions. - Submission wording and review-record correction only: previous execution logs retained; estimator code, tests and frozen evidence unchanged. - Not run: hosted/non-Linux CI, portable manylinux build, or fresh broad Monte Carlo qualification. Existing qualification failures remain documented.
|
Thanks, Charles. This is careful work and I want it in. Below is a fixed target; a line-by-line review comes once you mark it ready and will not reopen these points. Reference target. I wrote a formal review of the paper, in #909 (
What I verified: your tests pass merged with main; on balanced panels the results equal Your two questions
Precision cost that remains. Exclusion fixes coverage, not efficiency. With n=4,000, keeping pairs that have 20 to 50 treated units gives a spread of 0.069 to 0.092 for ATT(3,3), against about 0.045 when those pairs are dropped. Please document this. Precision-aware weighting, such as your count-weighted prototype, is a welcome follow-up but not a merge condition. Also accepted: the restricted experimental scope, and a coverage bar of about 0.94 in place of your exact-nominal gate, since the balanced-panel case is identical to Please document as choices the paper leaves open: the reference period and free pre-period parameters, the identity-weighting variance, and clustering. API alignment (changes requested)
I will handle the tutorial renumbering, condensing the methodology documents into the REGISTRY entry, and the plotter change on your branch. Please re-run the |
Context: - The maintainer fixed the target for PR igerber#887 in issue comment 7175894148, specified against the formal paper review merged in igerber#909. - The estimator kept thin pairs with a warning and aborted the whole fit when one pair's propensity logit failed. Its result API also differed from the other staggered estimators. - Two independent reviews ran before this commit. Their corrections are included. Changes: - Pair eligibility: exclude pairs with fewer than 20 observed units in either arm or control effective sample size below 20. The previous rule required two units and warned below 20. - Failure handling: a failed pair propensity fit excludes that pair with a recorded reason and detail, and the fit continues on the remaining paths. Only propensity-model failures are local. Outcome overflow still raises, with or without covariates. Warning categories other than UserWarning from the logit helper pass to the caller. - EPV: expose epv_threshold (default 10), enable the shared check and report per-cell epv_diagnostics from contributing pairs. A fit issues one summary warning for retained low-EPV pairs. - Result API, unreleased and without a compatibility alias: plain-dict cells with effect, se, t_stat, p_value, conf_int, n_treated, n_control and skip_reason; to_dataframe() uses effect and skip_reason; get_aggregation_weights_df(level) replaces aggregation_weights(level); add groups, time_periods, n_obs, cluster_name and n_clusters. - Table skip_reason columns have object dtype, so estimable cells hold None on pandas 2 and 3. n_obs counts observed outcomes. to_dict() returns a detached structure. - Documentation: identity GMM as the paper's named variant; the per-pair propensity fit as a deviation from the paper and from R under REGISTRY labels; the reference period, free pre-period parameters, identity sandwich and clustering as library choices; dispositions of the review's fourteen printed inconsistencies. - Evidence: cdid comparison re-run at 1.4.0.0 (R 4.5.2, did 2.5.1, DRDID 1.4.0) and a new sparse-policy report. Historical 1.1.0.0 records are unchanged. Limits: - Sparse grid, 2,000 replications per case: coverage is 0.9395 and 0.9345 in two of ten cases, so the literal 0.94 acceptance flag is false. This is consistent with the maintainer's bar of about 0.94, not a literal pass. - The incomplete continuous-covariate R fixture still differs, because the per-pair propensity criterion differs from cdid's by design. - Identity GMM ignores pair precision, so retained thin pairs cost precision. - The estimator predates docs/input-contract.md. It treats NaN outcomes as unobserved (IC-03 refuses them) and requires 0 as the never-treated marker (IC-15 also allows +inf). Both are left for the maintainer to rule on. - The reference image was upgraded in place; the tracked Dockerfile has not been built from clean. Verification: - Focused chained, methodology, doc-dependency and changelog tests: 477 passed on pandas 2.3.3. - Chained tests on pandas 3.0.3, NumPy 2.4.5 and SciPy 1.17.1: 139 passed. - ruff 0.17.1, black 26.10.1 and mypy 2.4.0 pass. - cdid 1.4.0.0 comparison: eight of nine fixtures pass, with the expected mismatch. Both reports were regenerated from this source. - Tutorial code cells executed. - Not run: hosted CI, the complete suite, the Python version matrix, the native backend, a clean rebuild of the reference image, and a simulation of the covariate path under the new policy. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Integrates igerber/diff-diff main at 7723c6d so that PR igerber#887 is current before review. The merge has no conflicts. Merged instead of rebased to keep the published PR head ecdd1e0 in the history. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Context: - The maintainer fixed the target for PR igerber#887 in issue comment 7175894148, specified against the formal paper review merged in igerber#909. - The estimator kept thin pairs with a warning and aborted the whole fit when one pair's propensity logit failed. Its result API also differed from the other staggered estimators. - Two independent reviews ran before this commit. Their corrections are included. Changes: - Pair eligibility: exclude pairs with fewer than 20 observed units in either arm or control effective sample size below 20. The previous rule required two units and warned below 20. - Failure handling: a failed pair propensity fit excludes that pair with a recorded reason and detail, and the fit continues on the remaining paths. Only propensity-model failures are local. Outcome overflow still raises, with or without covariates. Warning categories other than UserWarning from the logit helper pass to the caller. - EPV: expose epv_threshold (default 10), enable the shared check and report per-cell epv_diagnostics from contributing pairs. A fit issues one summary warning for retained low-EPV pairs. - Result API, unreleased and without a compatibility alias: plain-dict cells with effect, se, t_stat, p_value, conf_int, n_treated, n_control and skip_reason; to_dataframe() uses effect and skip_reason; get_aggregation_weights_df(level) replaces aggregation_weights(level); add groups, time_periods, n_obs, cluster_name and n_clusters. - Table skip_reason columns have object dtype, so estimable cells hold None on pandas 2 and 3. n_obs counts observed outcomes. to_dict() returns a detached structure. - Documentation: identity GMM as the paper's named variant; the per-pair propensity fit as a deviation from the paper and from R under REGISTRY labels; the reference period, free pre-period parameters, identity sandwich and clustering as library choices; dispositions of the review's fourteen printed inconsistencies. - Evidence: cdid comparison re-run at 1.4.0.0 (R 4.5.2, did 2.5.1, DRDID 1.4.0) and a new sparse-policy report. Historical 1.1.0.0 records are unchanged. Limits: - Sparse grid, 2,000 replications per case: coverage is 0.9395 and 0.9345 in two of ten cases, so the literal 0.94 acceptance flag is false. This is consistent with the maintainer's bar of about 0.94, not a literal pass. - The incomplete continuous-covariate R fixture still differs, because the per-pair propensity criterion differs from cdid's by design. - Identity GMM ignores pair precision, so retained thin pairs cost precision. - The estimator predates docs/input-contract.md. It treats NaN outcomes as unobserved (IC-03 refuses them) and requires 0 as the never-treated marker (IC-15 also allows +inf). Both are left for the maintainer to rule on. - The reference image was upgraded in place; the tracked Dockerfile has not been built from clean. Verification: - Focused chained, methodology, doc-dependency and changelog tests: 477 passed on pandas 2.3.3. - Chained tests on pandas 3.0.3, NumPy 2.4.5 and SciPy 1.17.1: 139 passed. - ruff 0.17.1, black 26.10.1 and mypy 2.4.0 pass. - cdid 1.4.0.0 comparison: eight of nine fixtures pass, with the expected mismatch. Both reports were regenerated from this source. - Tutorial code cells executed. - Not run: hosted CI, the complete suite, the Python version matrix, the native backend, a clean rebuild of the reference image, and a simulation of the covariate path under the new policy. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Integrates igerber/diff-diff main at 7723c6d so that PR igerber#887 is current before review. The merge has no conflicts. Merged instead of rebased to keep the published PR head ecdd1e0 in the history. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thanks for the fixed target. This revision implements it, and the branch is merged with main at Implemented
Coverage evidence On the ten-case sparse grid (2,000 replications per case, seed 20261106) no fit fails, but two cases fall below a literal 0.94 bar: 0.9395 (n=400, 50 treated and 19 controls at the extra date) and 0.9345 (n=4,000, 20 treated and 190 controls). The report's literal acceptance flag is therefore false. I did not change the threshold or the seed. On the same draws, intervals built from the known variance cover 0.942 and 0.946, so the shortfall from the HC0 variance is about 0.25 and 1.15 percentage points. An independent-seed replay of those two cases gave 0.945 and 0.942. I read this as coverage of about 0.94 at the 20-unit boundary: consistent with your stated bar, but not a literal all-case pass. Your sixteen-design result is cited as your evidence; I could not rerun the six additional designs. The precision cost remains as you described. In the retained 20/190 case the empirical SD is 0.0940, against about 0.0434 where the thin pairs are excluded. cdid 1.4.0.0 Eight of nine fixtures match, with maximum covariance discrepancy below 7e-15. The incomplete continuous-covariate fixture still differs, because the per-pair propensity criterion differs from cdid's by design. The comparison image was upgraded in place from the 1.1.0.0 image; the tracked Dockerfile has not been built from clean. Two choices to confirm
Each is a one-line change if you prefer the other behaviour. Input contract (#925) This estimator predates
Boolean outcomes are accepted and converted exactly, as Not verified The workflows on this PR are waiting for approval to run, so the Lint Gate has not executed. Locally, on the merged tree, ruff 0.17.1, black 26.10.1 and mypy 2.4.0 pass, and the ChainedDiD tests pass on pandas 2.3.3 and 3.0.3. I have not run the complete suite, the Python version matrix or the native backend. No simulation here covers the covariate path under the new exclusion policy; that rests on the simulations you reported. |
|
One addition to my note above. I said no simulation here covered the covariate path under the new exclusion rule. I have since rerun the existing 13-design qualification grid on the current head (2,000 replications per design, seed 20261102, one binary covariate). The report is not in the branch; I can add it if you want it.
I read the cohort-dependent result as the availability cost of the rule you set, not a calibration failure. I am flagging it because the ESS rule binds there with about 30 raw controls and a single binary covariate. |
613d5bd to
f8d80c0
Compare
|
I force-pushed to correct the author email on my two commits ( |
Add experimental native
ChainedDiDfor overlapping incomplete panels. It combines observed within-unit changes to recover group-time effects, using normalised per-pair IPW, never-treated controls, PT-post and identity GMM. Results keep original-unit population accounting, analytical unit or cluster covariance, canonical aggregation and explicit support diagnostics. The contract is restricted to binary absorbing treatment, zero anticipation and static complete covariates.This revision implements the fixed target and is merged with main at
7723c6de. My note lists the points that need a ruling, and a follow-up reports the covariate simulation.Methodology references (required if estimator / math changes)
docs/methodology/papers/bellego-2025-review.md(docs(methodology): Bellégo, Benatia & Dortet-Bernadet (2025) chained difference-in-differences paper review #909).cdiduses a response-calibrated pair score. Settled in the fixed target and recorded in REGISTRY.Validation
tests/test_chained_did*.pyandtests/test_methodology_chained_did.py. On the current head, the focused set passes (578 tests on pandas 2.3.3), and the ChainedDiD tests pass on pandas 3.0.3 with NumPy 2.4.5 and SciPy 1.17.1 (139 tests). ruff 0.17.1, black 26.10.1 and mypy 2.4.0 pass. The documentation builds with warnings as errors and the tutorial cells execute.cdid1.4.0.0 (R 4.5.2, did 2.5.1, DRDID 1.4.0): eight of nine fixtures match, with covariance discrepancy below 7e-15. The incomplete continuous-covariate fixture differs because the propensity criterion differs by design. The comparison image was upgraded in place; the tracked Dockerfile has not been built from clean.This contribution makes no general finite-sample calibration claim and no blanket R-parity claim.
Security / privacy
Changelog
changelog.d/20261102-chained-did.md.🤖 Generated with Claude Code