lp_did
Estimate dynamic treatment effects over event time via local-projections DiD, with cluster-robust standard errors and not-yet-treated or never-treated controls.
Instructions
Local-Projections DiD (Dube-Girardi-Jorda-Taylor 2023). At each event-time horizon h in {-P, ..., H}, runs a separate OLS of Y_{t+h} - Y_{t-1} on the treatment change Deltad_{t} with time FE and cluster-robust SE, using 'not-yet-treated' or 'never-treated' units as controls. Event-study beta_h paths are returned in model_info['event_study']. Validation: certified parity evidence. Assumptions: Parallel trends across event time (standard DiD); No anticipation within the pre-treatment horizon; SUTVA. Pre-conditions: long-format panel with consecutive integer time; treatment is binary 0/1 and time-varying; horizons feasible: enough periods for Y_{t-1} and Y_{t+H}. Failure modes: Horizon-0 n_obs is tiny because few units switch on in the clean-control window -> Widen clean_controls='never_treated' -> 'not_yet_treated' or shorten horizons; Placebo CIs don't cover zero -- parallel trends suspect -> Apply sp.honest_did to the event-study paths for Rambachan-Roth sensitivity bounds. Alternatives: sp.callaway_santanna, sp.sun_abraham, sp.did_imputation, sp.gardner_did. Typical minimum N: 100.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome variable column name or outcome array. | |
| time | Yes | Integer period (consecutive) | |
| unit | Yes | Unit identifier | |
| alpha | No | Significance level for confidence intervals and tests. | |
| 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 variable (defaults to unit) | |
| time_fe | No | time_fe parameter (bool). | |
| controls | No | Control-variable column names. | |
| horizons | No | (min, max) event-time horizons to estimate | |
| 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. | |
| treatment | Yes | Binary time-varying treatment (0/1) | |
| 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. | |
| clean_controls | No | Control selection | not_yet_treated |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||