Skip to content

Conversation

msukiasyan
Copy link

Adding support for cluster-robust standard errors.

Implementation:

  • Add clustered variance computation methods to StatsModelsLinearRegression and StatsModels2SLS classes, using existing groups parameter plumbing. Matches linearmodels package implementation.
  • Add cov_type parameter to OrthoIV constructor to expose the option since model_final isn't an argument.

File modifications:

  • econml/sklearn_extensions/linear_model.py - Added _compute_clustered_variance() methods
  • econml/iv/dml/_dml.py - Added cov_type parameter to OrthoIV class, pass groups parameter to model_final.
  • econml/dml/_rlearner.py - Pass groups parameter to model_final.
  • econml/tests/test_clustered_se.py - Tests validating against statsmodels implementation (up to small sample correction).

First contribution, so please let me know if I've missed anything!

- Implement clustered variance calculation in StatsModelsLinearRegression and StatsModels2SLS
- Add cov_type='clustered' parameter to OrthoIV estimator
- Add tests validating against statsmodels implementation

Signed-off-by: Mikayel Sukiasyan <mikayels@amazon.com>
… to handle groups=None

Signed-off-by: Mikayel Sukiasyan <mikayels@amazon.com>
Signed-off-by: Mikayel Sukiasyan <mikayels@amazon.com>
@msukiasyan msukiasyan marked this pull request as ready for review August 13, 2025 21:52
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.

1 participant