Address code review suggestions for covariate adjustment#24
Closed
Address code review suggestions for covariate adjustment#24
Conversation
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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.