overlap_weighted_did
Estimate causal effects with overlap-weighted difference-in-differences, down-weighting extreme propensity scores to improve balance when covariate overlap is poor.
Instructions
Overlap-weighted 2x2 DiD. Weights observations by e(X)(1-e(X)), where e(X) is the estimated propensity score, placing highest weight on units with the most overlap between treated and control covariate distributions. Useful when overlap is poor at the tails. Assumptions: Overlap weights target the sub-population with positive overlap; Correct PS model OR outcome model for DR variant; Conditional parallel trends given covariates X after overlap weighting. Pre-conditions: 2 periods, binary treat; covariates with variation; Two-period panel with a binary treat indicator and a binary pre/post time indicator. Failure modes: Propensity scores pile up near 0/1 giving near-zero overlap weights and unstable ATT -> Trim extreme-PS units or simplify the covariate set to restore common support; ps_model='dl' requested but the deep-learning propensity backend fails to converge -> Fall back to ps_model='logit' or 'gbm' for a more stable propensity estimate; More than two time periods passed to this 2x2-only estimator -> Collapse to a single pre/post contrast or use a staggered/multi-period estimator. Alternatives: sp.drdid, sp.did_2x2, sp.did, sp.callaway_santanna. Typical minimum N: 200.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome variable column name or outcome array. | |
| time | Yes | Time period column. | |
| alpha | No | Significance level for confidence intervals and tests. | |
| treat | Yes | Binary treatment indicator | |
| detail | No | Payload depth: 'minimal' (~150 tokens) for sub-step calls where only the point estimate is needed; 'standard' (~1K tokens) for diagnostics + coefficient table; 'agent' (~2K tokens, default) adds violations / next_steps / suggested_functions so the LLM can plan its next call without another round-trip. | agent |
| ps_model | No | Propensity score model | logit |
| as_handle | No | If true, cache the fitted result on the server and return result_id + result_uri alongside the JSON payload so a subsequent tools/call can chain without re-running. | |
| data_path | Yes | Absolute path or URL to a data file. Supported: .csv / .tsv / .txt (delimited), .parquet / .pq, .feather / .arrow, .xlsx / .xls, .dta (Stata), .json / .jsonl. Schemes: file://, s3://, gs://, https://. | |
| result_id | No | Optional handle to a previously-fitted result (returned by an earlier call when as_handle=true). Tools that operate on a fitted object accept this in place of re-supplying data_path + columns. | |
| covariates | Yes | Covariates X | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||