Add propensity score trimming and partition-specific collinearity checks#32
Merged
marcelortizv merged 4 commits intomainfrom Jan 23, 2026
Merged
Add propensity score trimming and partition-specific collinearity checks#32marcelortizv merged 4 commits intomainfrom
marcelortizv merged 4 commits intomainfrom
Conversation
- Add asymmetric trimming for control units with pscore >= 0.995 - Add trim_level parameter (default 0.995) to compute_pscore functions - Add keep_ps indicator to exclude poor counterfactual controls from ATT - Change upper bound from 1 - 1e-16 to 1 - 1e-6 (matches DRDID) - Apply trimming to ATT weights but NOT to nuisance estimation Trimming logic: - Treated units: always included (keep_ps = TRUE) - Control units: excluded if pscore >= trim_level (keep_ps = FALSE) This prevents numerical instability from IPW weights exploding when ps/(1-ps) approaches infinity for controls with ps near 1. Reference: DRDID package (drdid_panel.R, lines 122-143)
f327a65 to
feba1b8
Compare
Propensity Score Trimming (following DRDID approach): - Add asymmetric trimming for control units with pscore >= 0.995 - Add trim_level parameter (default 0.995) to compute_pscore functions - Add keep_ps indicator to exclude poor counterfactual controls from ATT - Change upper bound from 1 - 1e-16 to 1 - 1e-6 (matches DRDID) - Apply trimming to ATT weights but NOT to nuisance estimation Partition-Specific Collinearity Checks: - Add check_partition_collinearity() helper function - Detect covariates that are collinear only within specific subgroup comparisons - Two-stage checking: global collinearity first, then partition-specific - Informative warnings showing which partitions have collinearity issues Tests: - Add 6 unit tests for propensity score trimming functionality - Add Monte Carlo coverage test (1000 sims, n=2000, 2% tolerance) - Coverage test DGP triggers trimming (~10 controls per sim with ps >= 0.995) - Add 6 tests for partition-specific collinearity detection 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <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.
Summary
trim_levelparameter (default 0.995) tocompute_pscore()andcompute_pscore_rc()functionskeep_psindicator to exclude poor counterfactual controls from ATT estimation1 - 1e-16to1 - 1e-6(matches DRDID)Trimming Logic
ps < 0.995ps >= 0.995Why This Matters
Control units with propensity scores very close to 1 are problematic because:
ps/(1-ps) → ∞asps → 1Partition-Specific Collinearity
Added
check_partition_collinearity()helper that:Reference
DRDID package:
R/drdid_panel.R, lines 122-143