cgs_continuous_did
Measure how different treatment doses affect an outcome with continuous difference-in-differences, producing ATT(d) and ACRT(d) curves to answer marginal-dose questions.
Instructions
Callaway, Goodman-Bacon & Sant'Anna (2024) DiD with a CONTINUOUS treatment. A dose has no single ATT: the TWFE coefficient averages the 0.2-dose and 0.8-dose comparisons with weights that can be negative. Reports ATT(d) and its derivative ACRT(d) -- the causal response at dose d, which is what a marginal-dose question asks -- from a B-spline regression of the outcome change on the dose. Validation: certified evidence with scoped limitations. Known limitations: standard errors come from the per-cell influence function; contdid routes its own through the pte aggregation layer, which is not implemented here; staggered designs aggregate cells with StatsPAI's own treated-count weights; only the per-cell estimator is pinned against the reference; the cck (nonparametric) dose estimator is not implemented. Assumptions: Parallel trends in the untreated potential outcome; Strong parallel trends for ATT(d) to be the effect of dose d; No anticipation. Pre-conditions: panel with a continuous dose and some zero-dose units; at least one period before each treated cohort. Failure modes: No zero-dose units in a cell -> ATT(d) is levelled against the zero-dose group. Use control_group='notyettreate...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome variable column name or outcome array. | |
| dose | Yes | Treatment intensity (0 = untreated) | |
| time | Yes | Time period column. | |
| unit | Yes | Unit identifier column. | |
| alpha | No | Significance level for confidence intervals and tests. | |
| knots | No | Explicit interior knots | |
| cohort | Yes | First-treatment period (0 = never treated) | |
| degree | No | B-spline degree; degree=1 with no knots gives a constant ACRT, the 'effect per unit of dose' reading | |
| 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://. | |
| dose_grid | No | Doses to report the curves at (default: 10th-99th pct) | |
| num_knots | No | Interior knots at dose quantiles; more buys flexibility at the cost of variance and there is no auto-selector | |
| 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. | |
| curve_basis | No | 'fitted' evaluates the curves on the basis they were fitted on; 'reference' re-anchors to the dose grid to reproduce contdid 0.1.1's reported curves, which are a rescaled version of the fitted response | fitted |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| control_group | No | control_group parameter (str). | nevertreated |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||