Skip to content

Align shared Python kernels with R DRDID and CSDID - #21

Merged
pedrohcgs merged 8 commits into
d2cml-ai:mainfrom
pedrohcgs:fix/r-1.4-csdid-parity
Oct 27, 2026
Merged

pedrohcgs merged 8 commits into
d2cml-ai:mainfrom
pedrohcgs:fix/r-1.4-csdid-parity

Conversation

@pedrohcgs

@pedrohcgs pedrohcgs commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Python DRDID 1.1.6 can return the correct repeated-cross-section ATT with an incorrect influence vector and inference. An observed example differs from R by 5.35 in the IF. Omitted default weights also crash three functions, and missing propensity trimming changes estimates.

This corrects the six existing traditional DR, normalized IPW and regression kernels for panel and repeated-cross-section data. It repairs RC pre-period nuisance signs, R-compatible control trimming and final-probability propensity Hessians, default weights/covariates, input shapes, weighted designs and finite-weight normalization. Function names, tuple returns, the historical OLS helper and Python's automatic-intercept convention are preserved.

The coordinated candidates are DRDID 1.1.7 and CSDID 0.4.4. CSDID #88 requires exactly drdid==1.1.7 and records the reviewed source commit; a future backend version requires an explicit coordinated upgrade. CSDID uses local DR/IPW implementations with cached-fit support and imports DRDID for regression, so both copies are compared directly.

Validation:

  • 379 standalone tests pass, including 238 independent contracts, 80 full R configurations plus provenance, and 60 transformation cases. The 238 contracts give 130 failures on the original runtime; these include input/default contracts, not 130 distinct estimator defects.
  • Clean R DRDID eaac3b49 comparisons check ATT, every IF contribution, analytical SE and intervals, including zero/varying weights, trimming and outcome scales. Both raw and original-unit comparisons retain atol=1e-7, rtol=1e-6.
  • The exact proposed Git revisions were built into wheels and installed together in a fresh environment: 2,935 tests and 19 subtests pass, with no failures/errors/skips, plus all 72 direct CSDID comparisons. Runtime source, wheel and installed bytes and module origins are verified. The final installed pair also preserves 240 healthy CSDID workflows and 960 aggregates bit-for-bit against baseline.
  • All four CI jobs at 53a6b76 pass: Python 3.8/3.12, downstream CSDID integration and current official R parity. The exporter rebuilds native R code and binds the complete reviewed R tree and inputs; any upstream tree change requires review.

An unused orphan R gitlink without a .gitmodules URL was removed after GitHub checkout credential cleanup exposed it. All Python source bytes and fixtures remain identical to the full local installed proof; the final CI reruns the corrected repository tree.

Publication now requires a successful trusted same-repository main-push test workflow and builds that exact tested revision into both sdist and wheel. This PR is now merged. All four checks are mandatory on main under ruleset 25992066, with strict freshness and no bypass actors.

Scope is the six shared methods needed for CSDID. R's high-level default is improved/IPT; select traditional DR when comparing. Equivalent sample, design/intercept, weights, trimming and inference settings are required. R-only pushes are inspected on the next Python run and do not automatically port changes. CSDID's retained extreme-outcome raw aggregate-IF tolerance failures are disclosed in its compatibility record; this is not a universal numerical-equivalence claim.

See alignment/release notes, CSDID #88 and the companion aggregation correction R did #280.

Delivery update: merged as c238f57eee260565d5cd2a38526e2e6805aa9284. All four post-merge main CI jobs pass. The automatic release passed its source/CI gate, build and distribution checks, but PyPI rejected the upload with HTTP 403 Forbidden. Release 1.1.7 remains unpublished until publishing authentication/permissions are corrected. Mandatory CI is enforced by ruleset 25992066.

Copilot AI balanced review requested due to automatic review settings October 27, 2026 04:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@pedrohcgs

Copy link
Copy Markdown
Collaborator Author

@TJhon @alexanderquispe @anzonyquispe Can you put me as maintainer of the package so I have full control?

@pedrohcgs
pedrohcgs merged commit c238f57 into d2cml-ai:main Oct 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants