design_robust_event_study
Diagnose negative-weight contamination in staggered event-study designs and flag affected horizons, guiding robust estimation choices.
Instructions
Design-robust event study with explicit negative-weight diagnostics per cohort x relative-time cell. Reports which event-study coefficients receive negative weights in TWFE and flags the affected horizons. Assumptions: Parallel trends across cohorts; treatment effects may be heterogeneous across cohort and time; No anticipation prior to the event time; Implicit TWFE comparison weights are non-negative (negative-weight contamination is diagnosed, not assumed away). Pre-conditions: Long-format panel with y, treat, time, id (same conventions as callaway_santanna); Staggered/variable treatment timing so the per-(cohort, time) weight diagnostic is meaningful; Event-time window (leads, lags) contained within observed pre/post coverage. Failure modes: model_info weights show large negative TWFE weights flagging forbidden comparisons -> Drop already-treated controls and use a heterogeneity-robust staggered estimator instead of TWFE; Too few treated units per cohort-time cell to identify weights or SEs -> Coarsen the event-time window or pool cohorts to raise per-cell counts. Alternatives: sp.sun_abraham, sp.bacon_decomposition, sp.cohort_anchored_event_study, sp.callaway_santanna. Typical...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome variable column name or outcome array. | |
| id | Yes | Unit, subject, or panel identifier column. | |
| lags | No | lags parameter (int). | |
| time | Yes | Time period column. | |
| alpha | No | Significance level for confidence intervals and tests. | |
| leads | No | leads parameter (int). | |
| treat | Yes | Treatment indicator or first-treatment-period 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 |
| cluster | No | Cluster identifier column for clustered standard errors. | |
| 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. | |
| 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 | |||