Skip to content

Conversation

@igerber
Copy link
Owner

@igerber igerber commented Jan 3, 2026

Adds full covariate support to the CallawaySantAnna staggered DiD estimator:

  • Outcome regression (reg): Regresses outcome changes on covariates for control
    units, predicts counterfactual for treated
  • Inverse probability weighting (ipw): Estimates propensity scores via logistic
    regression, reweights control units to match treated covariate distribution
  • Doubly robust (dr): Combines both methods for consistent estimation if either
    the outcome model or propensity model is correctly specified

Implementation details:

  • Added _logistic_regression() and _linear_regression() helper functions
  • Updated _outcome_regression(), _ipw_estimation(), and _doubly_robust() to
    accept and use covariate matrices
  • Modified _compute_att_gt() to extract covariates from base period data
  • Graceful fallback to unconditional estimation if covariate extraction fails

Also includes:

  • 9 new tests for covariate adjustment across all estimation methods
  • Updated TODO.md to reflect completed implementation

…lel trends

Adds full covariate support to the CallawaySantAnna staggered DiD estimator:

- Outcome regression (reg): Regresses outcome changes on covariates for control
  units, predicts counterfactual for treated
- Inverse probability weighting (ipw): Estimates propensity scores via logistic
  regression, reweights control units to match treated covariate distribution
- Doubly robust (dr): Combines both methods for consistent estimation if either
  the outcome model or propensity model is correctly specified

Implementation details:
- Added _logistic_regression() and _linear_regression() helper functions
- Updated _outcome_regression(), _ipw_estimation(), and _doubly_robust() to
  accept and use covariate matrices
- Modified _compute_att_gt() to extract covariates from base period data
- Graceful fallback to unconditional estimation if covariate extraction fails

Also includes:
- 9 new tests for covariate adjustment across all estimation methods
- Updated TODO.md to reflect completed implementation
@igerber igerber merged commit fc222c2 into main Jan 3, 2026
@igerber igerber deleted the claude/implement-roadmap-priority-dyAWY branch January 3, 2026 23:15
igerber pushed a commit that referenced this pull request Jan 3, 2026
- Move scattered docstring notes to docs/reviews/pr22_covariate_adjustment_review.md
- Keep actual code fixes: removed unused self._covariates, fixed IPW influence function
- Keep new test for extreme propensity scores
igerber pushed a commit that referenced this pull request Jan 3, 2026
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 pushed a commit that referenced this pull request Jan 3, 2026
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 pushed a commit that referenced this pull request Jan 3, 2026
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
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.

3 participants