Fix _parse_formula to support covariates before interaction term #186
Open
SermetPekin wants to merge 1 commit intoigerber:mainfrom
Open
Fix _parse_formula to support covariates before interaction term #186SermetPekin wants to merge 1 commit intoigerber:mainfrom
SermetPekin wants to merge 1 commit intoigerber:mainfrom
Conversation
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.
Methodology references (required if estimator / math changes)
Method name(s): N/A — no estimator logic or math changed. This fixes a formula string parser, not the underlying estimation.
Paper / source link(s): N/A
Any intentional deviations from the source (and why): N/A
Validation
Tests added/updated: Added test_parse_formula.py with 6 tests covering:
Covariates before * (e.g. y ~ x1 + treated * post) — was broken, now fixed
Covariates on both sides of * (e.g. y ~ x1 + treated * post + x2) — was broken, now fixed
Multiple ~ gives clear error
Extra/no whitespace handling
Formula-vs-explicit-params equivalence (ATT and SE match to rtol=1e-10)
All 9 existing formula tests in test_methodology_did.py and test_estimators.py pass unchanged (no regressions)
Backtest / simulation / notebook evidence (if applicable): N/A
Security / privacy
Confirm no secrets/PII in this PR: Confirmed — changes are limited to formula parsing logic and test data generated with np.random.