harvest_did
Aggregate all valid 2x2 difference-in-differences comparisons from staggered panels into weighted average treatment effects for robust causal analysis.
Instructions
Harvest every valid 2x2 DID comparison from a staggered panel and aggregate them via precision-weighted / simple / cohort-weighted averages. Agnostic to cohort structure; useful for robustness comparisons against CS / SA / BJS. Assumptions: Parallel trends hold for every valid 2x2 sub-comparison being harvested and aggregated; No anticipation before each cohort's first treated period (reference horizon -1 is clean); Independence across units within each cohort (unit-level cluster-robust SEs); cross-horizon covariance ignored. Pre-conditions: Long-format panel with unit, time, outcome columns; Either a binary treat indicator or a precomputed cohort (first-treatment) column with a never_value marker; Multiple cohorts and overlapping periods so valid 2x2 comparisons exist across the requested horizons. Failure modes: No clean (never-treated or not-yet-treated) controls so no valid 2x2 cells can be harvested -> Add never-treated units or restrict horizons to periods with available clean controls; Precision weighting dominated by one tiny high-variance comparison distorts the aggregate -> Switch weighting to 'equal' or 'n_treated' to down-weight unstable cells. Alternatives: sp.callawa...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| time | Yes | Time period column. | |
| unit | Yes | Unit identifier column. | |
| alpha | No | Significance level for confidence intervals and tests. | |
| treat | No | Time-varying treat indicator (for dynamic harvesting) | |
| cohort | No | First-treat cohort column (for static harvesting) | |
| 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 |
| outcome | Yes | Outcome variable column name or outcome array. | |
| horizons | No | horizons parameter (list). | |
| 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://. | |
| reference | No | Pre-treatment reference horizon relative to each cohort | |
| 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. | |
| never_value | No | never_value parameter. | |
| 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 | |||