ddd_heterogeneous
Estimates heterogeneity-robust triple-differences for staggered adoption, decomposing effects by cohort and time with an unaffected subgroup as placebo to avoid negative-weight biases.
Instructions
Heterogeneity-robust triple differences (DDD) for staggered adoption. Decomposes DDD into per-(cohort, time) cells via a Callaway-Sant'Anna-style aggregation, with the unaffected subgroup's DID as a placebo. Avoids the negative-weight issue that textbook TWFE DDD inherits from TWFE DID (Goodman-Bacon 2021 analogue). Validation: certified evidence with scoped limitations. Known limitations: the placebo joint test is only produced on the bootstrap path; se='analytic' reports None for it, because that test needs the joint covariance of the placebo arms rather than of the DDD; control_group='notyettreated' is only partially comparable to triplediff 0.2.4: its per-control-cohort estimates agree exactly, but the reference misindexes the influence functions it combines, so the combined numbers differ by convention on cells where the comparison does not span the whole panel; the aggregation convention differs from triplediff::agg_ddd(type='simple'): the default weights cohorts by treated-eligible units; pass weight_by='cohort' to match the R package. Assumptions: Parallel trends relaxed to: same differential trend across treated vs never-treated, within both affected and unaffected subgro...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | No | Base-period covariates; identification becomes CONDITIONAL DDD parallel trends | |
| y | Yes | Outcome variable column name or outcome array. | |
| se | No | 'analytic' influence-function variance (exact, and what triplediff reports) or 'bootstrap' clustered on unit (the only path that fills in placebo_joint_test). Defaults to bootstrap without covariates, analytic with them | |
| seed | No | Random seed for reproducible stochastic steps. | |
| 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-treated) | |
| 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 | Number of bootstrap replications. | |
| subgroup | Yes | Binary within-group subgroup indicator (1=affected, 0=placebo) | |
| 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. | |
| weight_by | No | Aggregation weights: 'eligible' (treated units in the affected subgroup) or 'cohort' (whole cohort, both subgroups -- reproduces triplediff::agg_ddd) | eligible |
| est_method | No | Nuisance combination: doubly robust, inverse probability weighting, or outcome regression | dr |
| never_value | No | Value in cohort for never-treated units | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| control_group | No | Control units: never-treated, or not-yet-treated cohorts combined by minimum distance (see the docstring warning -- that path deliberately diverges from triplediff 0.2.4, which misindexes its influence functions there) | 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 | |||