did_analysis
Run a complete difference-in-differences analysis: auto-detect design, select the right estimator, and produce a diagnostic report with event study and sensitivity checks.
Instructions
Workflow wrapper that runs a full DiD pipeline: auto-detects 2x2 vs. staggered, runs the right estimator (CS by default), optionally runs Bacon decomposition, event study, and Rambachan-Roth sensitivity, and aggregates into a DIDAnalysis report object. Assumptions: Parallel trends between treated and control (2x2) or across cohorts (staggered) after any covariate adjustment; No anticipation: pre-treatment outcomes unaffected by future treatment; SUTVA / no interference across units; correct design auto-detection (2x2 vs staggered). Pre-conditions: Panel or repeated cross-section with y, treat, time; id required for staggered designs; treat is binary 0/1 for 2x2, or first-treatment period (0 = never-treated) for staggered; event_window within observed periods when run_event_study is enabled. Failure modes: Staggered design detected but no id column supplied, so cohorts cannot be formed -> Pass the unit identifier via id= so first-treatment cohorts can be inferred; Event-study pre-trend test rejects parallel trends in the bundled report -> Inspect the included honest_did sensitivity output and report bounds rather than the point ATT; Requested method incompatible with the detected d...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome variable column name or outcome array. | |
| id | Yes | Unit, subject, or panel identifier column. | |
| time | Yes | Time period column. | |
| treat | Yes | Binary treatment or first-treat column | |
| 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 | Estimator selection | auto |
| 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. | |
| run_bacon | No | run_bacon parameter (bool). | |
| 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. | |
| run_event_study | No | run_event_study parameter (bool). | |
| run_sensitivity | No | run_sensitivity parameter (bool). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||