Skip to content

Fix estimation, inference and preprocessing edge cases - #279

Merged
pedrohcgs merged 14 commits into
masterfrom
codex/fix-stress-test-findings
Oct 27, 2026
Merged

pedrohcgs merged 14 commits into
masterfrom
codex/fix-stress-test-findings

Conversation

@pedrohcgs

Copy link
Copy Markdown
Collaborator

Valid weighted cells could be discarded by unweighted feasibility checks, changing outcome units could remove standard errors and alter Wald restrictions, and balance_e could mix cohorts after missing cells were removed. This corrects those paths, restores pending fixes, and adds reproductions and performance measurements.

Changes:

  • Use positive normalized support for overlap checks and the actual weighted control Gram matrix for regression feasibility. Keep the unweighted path free of weight scans and unnecessary copies. Require DRDID >= 1.4.0.
  • Keep common originally observed event-time support when balancing dynamic effects, before applying display limits. Count distinct group/event pairs in one pass.
  • Preserve finite positive standard errors regardless of outcome units; retain exact-zero/nonfinite handling and the Wald covariance singularity check. Reuse the bootstrap critical value and preserve matrix dimensions with a single bootstrap draw.
  • Fix data-column/local-variable collisions in fast preprocessing and resolved formula, observation-ID, and panel flags in the conditional pretest.
  • Restrict the legacy conditional pretest to its justified IPW method, with a clear error for reg/DR/custom methods and documentation of fixed panel conditioning variables. att_gt() still supports those estimators.
  • Forward-port Use the base period g - anticipation - 1 for anticipation periods and keep them out of the pre-test #276's anticipation estimates and pretest correction into a branch based on master, and include Restore tiny-group RC coverage and reject undersized outcome fits #278's normalized tiny-group RC guards and restored tests. This incorporates the changes from Restore tiny-group RC coverage and reject undersized outcome fits #278; that PR remains open.

Validation on the final source:

  • Full local suite: 4,059 assertions passed, zero failures, warnings or skips.
  • Clean-source R CMD check --as-cran --no-manual: Status: OK, including rendered and rebuilt vignettes.
  • Independent refit checks: 640 configurations / 31,680 cell-level influence-function comparisons; 432 independent base-R ATT configurations / 8,064 nuisance fits. No discrepancy beyond numerical tolerance.
  • Optimized support logic: 19,997 exact selector comparisons, 1,000 complete aggregation/error comparisons, and 4,000 independent RC-support decisions pass.
  • Independent source review and targeted R counterexamples verified the single-draw shape and irregular-base fixes.

Performance was compared with clean master 74b88eb under the same DRDID 1.4.0, with warmups and 14 measurements per source/case in separate ABBA processes. No material end-to-end slowdown was detected across 28 main and 12 targeted workloads. Initial targeted regressions were investigated and optimized; their raw measurements are retained.

Workload Master median Fixed median
Weighted fast panel, n=5,000 71.5 ms 67.5 ms
Bootstrap fast panel, n=5,000 81.5 ms 78 ms
Slow varying-weight DR, n=5,000 169 ms 170 ms
Balanced dynamic effects, n=3,000, T=12 9 ms 9 ms

The slow varying-weight timing ranges overlap. The corrected weighted rank guard and exceptional zero/underflow fallback paths have small isolated costs, disclosed rather than hidden. These timings are evidence for the tested workloads, not a universal performance bound. Reproducible scripts, raw timings, medians and IQRs are excluded from the built R package.

Cross-platform pre-PR validation on exact commit 04a1b09:

Limits: retaining a positive computed variance does not establish that an extremely tiny nuisance-fit residual is statistically meaningful; extreme scales can still exceed floating-point range. The preliminary overlap diagnostic retains its existing unweighted policy on positive support. No new regression/DR conditional-test procedure is introduced.

… keep them out of the pre-test

With anticipation > 0, periods g - anticipation, ..., g - 1 are periods in which
units may already respond to the treatment (Callaway and Sant'Anna, 2021).
Under base_period = "varying" they used period t - 1 as the base, so with
anticipation >= 2 the cells inside the window (other than the first) were
changes between two anticipation periods; and they entered the Wald pre-test,
which then rejected parallel trends because of the anticipation the user had
declared (20 of 20 simulated samples with true parallel trends).

Both compute paths now use the base period g - anticipation - 1 for every
t >= g - anticipation, and the pre-test (and the pretest-only cell filter)
uses only t < g - anticipation. anticipation = 0 and all post-treatment cells
are unchanged. Docs updated (?att_gt anticipation/base_period/weights, ?MP W).
Copilot AI balanced review requested due to automatic review settings October 26, 2026 23:10

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.

@pedrohcgs
pedrohcgs merged commit 2d7390a into master Oct 27, 2026
16 of 17 checks passed
github-actions Bot added a commit that referenced this pull request Oct 27, 2026
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