continuous_did
Estimate causal effects of a continuous treatment dose using difference-in-differences. Choose from TWFE, group-time ATT, dose-response, or CGS methods for panel data.
Instructions
DiD with continuous treatment intensity. Four modes: (i) 'twfe' TWFE with dosexpost interaction; (ii) 'att_gt' dose-quantile group-time ATT versus the untreated (dose=0) arm with bootstrap SE (heuristic); (iii) 'dose_response' local-linear regression of DeltaY=Y_post-Y_pre on baseline dose; (iv) 'cgs' Callaway-Goodman-Bacon-Sant'Anna (2024) ATT(d|g,t) MVP -- 2-period design, OR only, bootstrap SE, [pending verification] markers on paper formulas. Full CGS parity (cohort aggregation, DR/IPW, analytical IF variance) is on the roadmap -- see docs/rfc/continuous_did_cgs.md. Validation: validated evidence tier (known-truth, reference, external-parity, or Monte Carlo artifact). Known limitations: method='cgs' is an MVP -- 2-period design, OR only, bootstrap SE; full CGS parity (cohort aggregation, DR/IPW, analytical IF variance) is on the roadmap (see docs/rfc/continuous_did_cgs.md). Other modes (twfe / att_gt / dose_response) are stable. Assumptions: Parallel trends in potential outcomes across dose levels; No anticipation of treatment; Strong parallel trends (CGS 2024) required for ATT(d|g,t) interpretation in att_gt mode. Pre-conditions: panel data with unit x time x outcome x contin...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome variable | |
| id | Yes | Unit identifier | |
| dose | Yes | Continuous treatment / dose variable | |
| post | No | Binary post-treatment indicator (inferred from t_pre / t_post if omitted) | |
| seed | No | Random seed for reproducible stochastic steps. | |
| time | Yes | Time period column | |
| alpha | No | Significance level for confidence intervals and tests. | |
| t_pre | No | Last pre-treatment period | |
| 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 |
| method | No | Estimation mode | att_gt |
| n_boot | No | Bootstrap replications for SE | |
| t_post | No | First post-treatment period | |
| cluster | No | Cluster variable for SE (TWFE mode) | |
| controls | No | Control variables | |
| 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. | |
| n_quantiles | No | Number of dose quantiles for discretisation | |
| 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 | |||