did_multiplegt
Estimates causal effects of a binary treatment that can switch on and off in panel data, using consecutive-period DID that compares switchers to stayers. Supports placebo lags, dynamic horizons, and cluster bootstrap.
Instructions
de Chaisemartin & D'Haultfuille (2020) DID_M estimator. Weighted average of consecutive-period DID cells where treatment 'switchers' are compared to 'stayers'. Handles treatments that switch on AND off (unlike Callaway-Sant'Anna which assumes staggered adoption). Supports placebo lags, dynamic horizons, cluster bootstrap SE, joint placebo test and average-cumulative-effect summary from dCDH (2024). The heteroskedastic-weights variant and full dCDH (2024) intertemporal event-study (did_multiplegt_dyn Stata) are on the roadmap -- see docs/rfc/multiplegt_dyn.md. Validation: certified parity evidence. Assumptions: Parallel trends between switchers and stayers; Stable treatment effects across consecutive periods (for the DID_M weighted average interpretation); No anticipation. Pre-conditions: long-format panel with one row per unit x period; treatment is binary (0/1) and may vary over time within a unit; at least two periods observed per unit so a first difference can be computed. Failure modes: No switching cells (nobody changes treatment) -> did_multiplegt identifies effects only from treatment switches. Fall back to callaway_santanna if the design is staggered adoption; Joint placeb...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome variable | |
| seed | No | Random seed for reproducible stochastic steps. | |
| time | Yes | Time period column | |
| alpha | No | Significance level for confidence intervals and tests. | |
| group | Yes | Unit identifier | |
| 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 |
| n_boot | No | Cluster-bootstrap replications | |
| cluster | No | Cluster variable for bootstrap (defaults to group) | |
| dynamic | No | Number of post-treatment dynamic horizons | |
| placebo | No | Number of pre-treatment placebo lags | |
| controls | No | Controls residualised via first differences | |
| 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 current-treatment indicator (may switch on and off) | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| placebo_sign | No | Placebo sign convention. dCDH's own Stata and R packages disagree: on did::mpdta both give |placebo_1| = 0.024269 with identical effects, but opposite signs. Default keeps Stata's | stata |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||