Skip to content

Address code review suggestions for covariate adjustment#24

Closed
igerber wants to merge 1 commit intomainfrom
claude/implement-roadmap-priority-dyAWY
Closed

Address code review suggestions for covariate adjustment#24
igerber wants to merge 1 commit intomainfrom
claude/implement-roadmap-priority-dyAWY

Conversation

@igerber
Copy link
Copy Markdown
Owner

@igerber igerber commented Jan 3, 2026

No description provided.

Changes based on PR #22 review:

1. Remove unused self._covariates instance variable
   - Was stored but never accessed; covariates passed through method chain

2. Fix empty influence function in unconditional IPW
   - Previously returned np.array([]) placeholder
   - Now properly computes influence function matching other methods

3. Add docstring example for covariate adjustment
   - Shows doubly robust usage with covariates

4. Add edge case tests:
   - test_extreme_propensity_scores: verifies clipping handles near-perfect separation
   - test_near_collinear_covariates: verifies lstsq handles ill-conditioned matrices
   - test_missing_values_in_covariates_warning: verifies fallback warning path
@igerber igerber closed this Jan 3, 2026
@igerber igerber deleted the claude/implement-roadmap-priority-dyAWY branch January 4, 2026 00:03
igerber added a commit that referenced this pull request Apr 19, 2026
Three long-standing axis-E (silent data sanitization) sites now emit a
UserWarning with the affected row count before the coercion, so users
can no longer be silently shifted between the treated and control
sides of an estimator or have rows vanish from a diagnostic pass
without a signal.

- WooldridgeDiD: NaN cohort values were filled to 0 (never-treated)
  both in `_filter_sample` and in `fit()`. Both now warn with the
  NaN row count before the fillna (finding #24).
- ContinuousDiD: `first_treat=inf` was replaced with 0 silently.
  `fit()` now counts inf rows and warns before the replace, before
  any downstream drop-zero-dose / negative-dose validation
  (finding #26).
- `_compute_outcome_changes` (the `check_parallel_trends` diff
  helper) dropped NaN first-differences without reporting the count.
  It now distinguishes the expected first-period-per-unit drops
  from excess drops caused by gaps / NaN outcomes and warns with
  the breakdown when excess drops are detected (finding #27).

Finding #25 (TROP D-matrix coercion) was verified during scoping to
already be resolved in `trop_local.py:60-66` via `n_missing_structural`
+ returned `missing_mask`; no code change required.

REGISTRY updated under both WooldridgeDiD and ContinuousDiD to
document the new warning contract.

Covered by audit axis E (data sanitization). Findings #24, #26, #27
from docs/audits/silent-failures-findings.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
igerber added a commit that referenced this pull request Apr 19, 2026
Three long-standing axis-E (silent data sanitization) sites now emit a
UserWarning with the affected row count before the coercion, so users
can no longer be silently shifted between the treated and control
sides of an estimator or have rows vanish from a diagnostic pass
without a signal.

- WooldridgeDiD: NaN cohort values were filled to 0 (never-treated)
  both in `_filter_sample` and in `fit()`. Both now warn with the
  NaN row count before the fillna (finding #24).
- ContinuousDiD: `first_treat=inf` was replaced with 0 silently.
  `fit()` now counts inf rows and warns before the replace, before
  any downstream drop-zero-dose / negative-dose validation
  (finding #26).
- `_compute_outcome_changes` (the `check_parallel_trends` diff
  helper) dropped NaN first-differences without reporting the count.
  It now distinguishes the expected first-period-per-unit drops
  from excess drops caused by gaps / NaN outcomes and warns with
  the breakdown when excess drops are detected (finding #27).

Finding #25 (TROP D-matrix coercion) was verified during scoping to
already be resolved in `trop_local.py:60-66` via `n_missing_structural`
+ returned `missing_mask`; no code change required.

REGISTRY updated under both WooldridgeDiD and ContinuousDiD to
document the new warning contract.

Covered by audit axis E (data sanitization). Findings #24, #26, #27
from docs/audits/silent-failures-findings.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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