Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

staggered_rollout

Read-only

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

TableJSON Schema
NameRequiredDescriptionDefault
gYesFirst-treatment period; never-treated may be 0, NaN or inf
iYesUnit identifier
tYesTime period
yYesOutcome variable column name or outcome array.
alphaNoSignificance level for confidence intervals and tests.
detailNoPayload 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
fisherNoRun a Fisher randomisation test by permuting adoption dates across units; p-value in model_info['fisher_pvalue']
se_typeNoWhich 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_infoneyman
estimandNoWeighting: 'simple' (per treated cell), 'cohort' (within-cohort average first), 'calendar' (within-period average first), 'eventstudy' (ATT event_time periods after adoption)simple
n_fisherNoPermutation draws for the randomisation test
as_handleNoIf 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_pathYesAbsolute 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://.
efficientNoUse the optimal pre-period control weights; False gives the plug-in estimator (R's beta=1)
result_idNoOptional 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_timeNoOnly read when estimand='eventstudy'. A list returns one row per event time in .detail with the joint covariance in model_info['vcov']
use_did_a0NoWhich 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_columnsNoOptional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads.
random_stateNoSeed for the permutation draws
data_sample_nNoOptional uniform random subsample size (seed=0, deterministic) — useful on huge panels.
use_last_treated_onlyNoRestrict controls to the last-treated cohort (the Sun-Abraham comparison group) instead of every not-yet-treated cohort

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already provide readOnlyHint=true and openWorldHint=false, and the description reinforces this read-only nature without contradicting it. It goes beyond annotations by disclosing edge-case behavior ('single-unit cohorts are dropped with a warning'), the identifying assumption (random treatment timing; parallel trends neither assumed nor sufficient), and validation status ('certified parity evidence'). This is exactly the kind of context an agent needs to interpret warnings and results.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with a one-line purpose and immediately delivers usage guidance, assumptions, and alternatives. It is somewhat long and repeats 'balanced panel' in both Assumptions and Pre-conditions, but every section earns its place for a 20-parameter econometric tool with nuanced identification requirements.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (20 parameters, 5 required, output schema present), the description is remarkably complete. It covers the identifying assumption, when to use it, when not to, exact alternatives, data-shape preconditions, an edge-case warning, and a typical sample-size threshold. With an output schema already defined, nothing an agent needs to decide whether to call this tool is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds no parameter-specific meaning beyond what the schema already provides; for example, 'efficient=False gives the plug-in' is redundant with the schema's 'False gives the plug-in estimator (R's beta=1)'. No parameter is otherwise clarified or expanded.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with 'Efficient DiD for a randomised staggered rollout (Roth & Sant'Anna 2023)' and immediately clarifies the identifying assumption: 'Identifies off random adoption *timing*, not parallel trends'. It explicitly contrasts with 'the wrong one for observational rollouts' and names sibling estimators, so an agent can distinguish this tool from callaway_santanna, did_imputation, and sun_abraham without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit when-to-use guidance ('right estimator for policy lotteries, phased launches and wave-randomised RCTs'), an explicit exclusion ('Do NOT use when: adoption timing was not randomised'), a concrete alternative ('use a parallel-trends estimator such as sp.callaway_santanna instead'), and a list of alternatives. It also states preconditions (balanced panel, at least two cohorts) and a typical minimum N, leaving no ambiguity about suitability.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools