spillover_did
Estimate direct and indirect treatment effects with difference-in-differences using distance-based rings and clean controls beyond the outer ring to avoid contamination.
Instructions
Butts spillover-ring DiD. The usual fix -- a spatial lag of treatment in a TWFE regression -- measures the direct effect against controls the spillover already reached. This sorts untreated units by distance to the nearest treated unit into spillover rings plus CLEAN controls beyond every ring, and estimates the direct effect and each ring's effect against the clean controls only. Validation: validated evidence tier (known-truth, reference, external-parity, or Monte Carlo artifact). Known limitations: there is no reference implementation, so this carries design-recovery evidence only and no cross-language parity; ring boundaries are the analyst's choice; there is no selector, and a too-wide outer ring silently contaminates the clean controls; covariate adjustment is not implemented. Assumptions: Parallel trends between each group and the clean controls; Spillovers vanish beyond the outermost ring; No anticipation. Pre-conditions: unit positions or a distance matrix; some untreated units beyond the outermost ring. Failure modes: No clean controls -> Every untreated unit is inside a ring. Narrow ring_edges or widen the study area; Ring effects do not decay with distance -> The outer...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome variable column name or outcome array. | |
| time | Yes | Time period column. | |
| unit | Yes | Unit identifier column. | |
| alpha | No | Significance level for confidence intervals and tests. | |
| cohort | Yes | First-treatment period (never_value = never) | |
| coords | No | Two columns giving each unit's position (Euclidean) | |
| 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 |
| 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://. | |
| distances | No | Pre-computed distance matrix, for great-circle or network distances | |
| 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. | |
| ring_edges | No | Ring boundaries; untreated units beyond the last edge are the clean controls | |
| 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 | |||