cohort_anchored_event_study
Avoids cohort contamination in staggered adoption studies by estimating separate event-study paths per cohort and aggregating with cohort weights for cluster-robust treatment effects.
Instructions
Cohort-anchored event study. Instead of averaging across cohorts at each relative-time bin (which can contaminate leads / lags with other cohorts' dynamics), estimates separate event-study paths per cohort and then aggregates with cohort weights. Standard errors are cluster-robust and carry no protection against parallel-trends violations: this is the cohort-anchored estimator Liu (2025) starts from, NOT that paper's block-bias robust-inference procedure, which is not implemented. For parallel-trends sensitivity use sp.honest_did. Assumptions: Parallel trends hold within each treatment cohort relative to never-treated units (cohort-anchored, not pooled TWFE); No anticipation: outcomes in pre-event periods unaffected by future treatment; Treatment is an absorbing first-treatment event (staggered adoption, treat encodes first period, 0 = never-treated). Pre-conditions: Long-format balanced/unbalanced panel with id and time columns; treat column gives first-treatment period per unit (0 = never-treated), with at least one never-treated cohort; Enough pre/post periods to fill the requested leads/lags event-time window. Failure modes: All units treated in same period / no never-treated...
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 | |||