[Repo Assist] fix: raise ValueError for unsupported identifier_method in covariate adjustment estimators#1442
Conversation
…adjustment estimators Estimators based on covariate adjustment (linear regression, generalized linear model, propensity score methods, distance matching) silently produced incorrect results when used with incompatible identification strategies (frontdoor, iv, mediation). Add a clear ValueError to RegressionEstimator.fit(), PropensityScoreEstimator.fit(), and DistanceMatchingEstimator.fit() that fires before any computation when identifier_method is not one of 'backdoor' or 'general_adjustment'. This follows the same pattern already established by DoublyRobustEstimator. Also add parametrized tests to TestLinearRegressionEstimator that verify the ValueError is raised for 'frontdoor', 'iv', and 'mediation'. Closes #618 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
When using the functional API (identify_effect()), identifier_method is not set and defaults to None. The previous whitelist check would raise a ValueError for None, breaking the functional API notebook test. Change the check to only raise for explicitly unsupported methods (frontdoor, iv, mediation) while allowing None to pass through. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
|
Commit pushed:
|
|
🤖 This is an automated update from Repo Assist. CI fix: Pushed commit Root cause of the failure: The validation check used a whitelist ( Fix: Changed the check to
Also added a regression test Note 🔒 Integrity filter blocked 75 itemsThe following items were blocked because they don't meet the GitHub integrity level.
To allow these resources, lower tools:
github:
min-integrity: approved # merged | approved | unapproved | none
|
…cation-validation-068f80d9d620c11b
🤖 This PR was created by Repo Assist, an automated AI assistant.
Closes #618
Root Cause
Covariate-adjustment estimators (
LinearRegressionEstimator,GeneralizedLinearModelEstimator, allPropensityScore*estimators, andDistanceMatchingEstimator) silently produced incorrect results when used with incompatible identification strategies such asfrontdoor,iv, ormediation.When
identifier_methodis"frontdoor",get_adjustment_set()falls back to returning empty backdoor variables, causing the estimator to run without the right covariates and yielding a biased, incorrect effect estimate — without any error or warning.DoublyRobustEstimatoralready has this guard; the other covariate-adjustment estimators did not.Fix
Add an early
ValueErrorto thefit()methods of:RegressionEstimator(coversLinearRegressionEstimatorandGeneralizedLinearModelEstimator)PropensityScoreEstimator(coversPropensityScoreMatchingEstimator,PropensityScoreWeightingEstimator,PropensityScoreStratificationEstimator)DistanceMatchingEstimatorThe check fires before any computation and gives a clear message directing users to
TwoStageRegressionEstimator(for frontdoor/mediation) orInstrumentalVariableEstimator(for iv).TwoStageRegressionEstimatoris unaffected because it already overridesidentifier_methodto"backdoor"on the internal estimand copies it passes to regression sub-estimators.Tests
Added
test_invalid_identifier_method_raisestoTestLinearRegressionEstimator, parametrized overfrontdoor,iv, andmediation.Test Status
All estimator tests pass, including the existing two-stage regression (frontdoor) tests which confirm the internal
identifier_method = "backdoor"override is unaffected by this change.Note
🔒 Integrity filter blocked 55 items
The following items were blocked because they don't meet the GitHub integrity level.
list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: