drdid
Estimate 2x2 difference-in-differences causal effects with covariates using a doubly-robust combination of outcome regression and inverse probability weighting; consistent if either nuisance model is correct.
Instructions
Doubly-robust DiD (Sant'Anna & Zhao 2020). Combines outcome regression with IPW; consistent if either model is correct. Primary estimator for 2x2 DiD with covariates. Validation: certified parity evidence. Assumptions: Conditional parallel trends given X; Overlap / positivity: 0 < P(D=1|X) < 1; Correct specification of at least one nuisance model. Pre-conditions: panel or repeated cross-section with 2 periods; group is a binary unit-level treatment indicator; covariates have non-zero variance and overlap. Failure modes: Propensity score near 0/1 (overlap violation) -> Trim extreme propensity scores or use sp.ipw_trim. Alternatives: sp.did_2x2, sp.callaway_santanna, sp.wooldridge_did. Typical minimum N: 100.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome variable | |
| id | No | Unit identifier for true two-period panel DR-DID | |
| seed | No | Random seed for reproducible stochastic steps. | |
| time | Yes | Time period column | |
| alpha | No | Significance level for confidence intervals and tests. | |
| group | Yes | Unit-level treatment indicator (0/1) | |
| 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 |
| method | No | Nuisance estimators for est_method='dr' (R DRDID::drdid(estMethod=)): 'imp' uses inverse probability tilting + odds-weighted least squares so the DR moment is Neyman-orthogonal by construction; 'trad' uses plain logit + OLS with the estimation effects propagated. Ignored unless est_method='dr'. | imp |
| n_boot | No | Deprecated / inert: standard errors come from the Sant'Anna-Zhao influence function on every path. | |
| weights | No | Observation weights column (R DRDID i.weights), renormalised to mean one. | |
| 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 | No | Covariates X | |
| est_method | No | Estimator family. With method/normalized/locally_efficient and id=, this reaches all 14 R DRDID 1.2.3 estimators: dr -> drdid_[imp_]panel / drdid_[imp_]rc[1]; ipw -> [std_]ipw_did_panel|rc; reg -> reg_did_panel|rc; twfe -> twfe_did_panel|rc. 'twfe' is for comparison, not recommendation: with covariates it is the specification Sant'Anna-Zhao and Caetano-Callaway warn about. | dr |
| normalized | No | est_method='ipw' only. True = Hajek-normalised (std_ipw_did_*), control arm divided by its own weight mass. False = Abadie (2005) (ipw_did_*), both arms sharing the denominator E[D]. | |
| trim_level | No | Drop control units whose propensity score reaches this cutoff (DRDID trim.level). 1.0 disables. | |
| 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. | |
| locally_efficient | No | est_method='dr' on repeated cross-sections only. False drops the semiparametric-efficiency terms, giving drdid_rc1 / drdid_imp_rc1, which avoid fitting outcome regressions on the treated cells. Both are consistent. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||