staggered_rollout
Estimate causal effects from randomized staggered rollout timing, using pre-treatment moments as optimal controls; for policy lotteries, phased launches, and wave-randomized RCTs.
Instructions
Efficient DiD for a randomised staggered rollout (Roth & Sant'Anna 2023). Identifies off random adoption timing, not parallel trends, so it is the right estimator for policy lotteries, phased launches and wave-randomised RCTs -- and the wrong one for observational rollouts. Uses the cohort's pre-treatment moments as optimal controls; efficient=False gives the plug-in. Validation: certified parity evidence. Do NOT use when: adoption timing was not randomised -- use a parallel-trends estimator such as sp.callaway_santanna instead. Assumptions: treatment timing is randomly assigned (this is the identifying assumption; parallel trends is neither assumed nor sufficient); balanced panel. Pre-conditions: balanced panel with at least two cohorts; single-unit cohorts are dropped with a warning, matching R staggered: their within-cohort covariance is not estimable. Alternatives: sp.callaway_santanna, sp.did_imputation, sp.sun_abraham. Typical minimum N: 50.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| g | Yes | First-treatment period; never-treated may be 0, NaN or inf | |
| i | Yes | Unit identifier | |
| t | Yes | Time period | |
| y | Yes | Outcome variable column name or outcome array. | |
| alpha | No | Significance level for confidence intervals and tests. | |
| 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 |
| fisher | No | Run a Fisher randomisation test by permuting adoption dates across units; p-value in model_info['fisher_pvalue'] | |
| se_type | No | Which SE lands in .se: 'neyman' is the conservative bound; 'adjusted' subtracts the variance the randomisation identifies and is what R staggered prints. Both are always in model_info | neyman |
| estimand | No | Weighting: 'simple' (per treated cell), 'cohort' (within-cohort average first), 'calendar' (within-period average first), 'eventstudy' (ATT event_time periods after adoption) | simple |
| n_fisher | No | Permutation draws for the randomisation test | |
| 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://. | |
| efficient | No | Use the optimal pre-period control weights; False gives the plug-in estimator (R's beta=1) | |
| 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. | |
| event_time | No | Only read when estimand='eventstudy'. A list returns one row per event time in .detail with the joint covariance in model_info['vcov'] | |
| use_did_a0 | No | Which controls the efficient weights are chosen over. True uses the single DiD contrast at g-1; False uses every pre-period as a separate control (the general form, weakly more efficient). False requires efficient=True | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| random_state | No | Seed for the permutation draws | |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. | |
| use_last_treated_only | No | Restrict controls to the last-treated cohort (the Sun-Abraham comparison group) instead of every not-yet-treated cohort |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||