Repository navigation
fix: normalize SSM inverse probability weights to mean one with normalize_ipw - #427
Merged
Merged
Conversation
…lize_ipw With normalize_ipw=True, DoubleMLSSM scaled the inverse probability weights by sum(d) / sum(d * s / (m * pi)) (and the analogue for the controls), which is approximately P(D = d) instead of one. This shrank the bias correction of the doubly robust score and biased the estimate when the outcome model is misspecified. Normalize by n / sum(d * s / (m * pi)), as in the reference implementation causalweight::treatselDML. Apply the same fix to the manual implementation used in the tests and add a regression test for the normalized weights.
SvenKlaassen
approved these changes
Oct 31, 2026
Member
|
Thanks @vrjdev, I pushed a small follow-up. The idea is that Changes:
Both new tests fail on the old formula. All SSM tests pass. Does this look fine to you? |
Contributor
Author
|
Thanks @SvenKlaassen , looks good to me. Writing it with |
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.
Description
With
normalize_ipw=True,DoubleMLSSMrescaled the inverse probability weights bysum(d) / sum(d * s / (m * pi)), and by the analogue for the controls. That factor is roughly P(D = d) instead of about one. It shrank the bias-correction term of the doubly robust score, so estimates were biased whenever the outcome model was poor, even with correct propensity models.doubleml/irm/ssm.py: normalize withlen(y) / sum(...), so that the weights average to one in each treatment arm. This matches the reference implementationcausalweight::treatselDML(nrow(...) * ... / sum(...)). The change applies to both scores,missing-at-randomandnonignorable.doubleml/irm/tests/_utils_ssm_manual.py: the same fix in the manual implementation, which had the same formula.test_ssm.pynow checks the correct normalization.New
doubleml/irm/tests/test_ssm_normalize_ipw.py, modelled ontest_iivm_normalize_ipw.pyfrom Fix IIVM normalize_ipw: normalize with the instrument z #413. It checks two things:It fails before the fix.
Reference to Issues or PRs
Fixes #426
Comments
Monte Carlo check: 60 replications, n = 4,000, correctly specified logistic models for
mandpi, a constant outcome model (DummyRegressor), true ATE = 1.normalize_ipw=Falsenormalize_ipw=True, beforenormalize_ipw=True, afterThe R package has the same formula in
R/double_ml_ssm.R(lines 640-641).PR Checklist