Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

did_2stage

Read-only

Estimate causal treatment effects with Gardner's two-stage difference-in-differences, handling heterogeneous effects and avoiding biased two-way fixed-effect comparisons.

Instructions

Gardner (2021) two-stage DID estimator. Assumptions: Conditional parallel trends between treated and comparison groups absent treatment; No anticipation of treatment before its onset; Treatment effects may be heterogeneous across cohorts and time (no homogeneity required). Pre-conditions: Panel or repeated cross-section with a unit (or group) identifier and a time identifier; At least one never-treated or not-yet-treated comparison group; Pre-treatment periods to assess parallel trends. Failure modes: Pre-treatment event-study coefficients are jointly non-zero (pre-trend violation) -> Use honest DiD bounds to quantify robustness to trend violations, or condition on covariates; Two-way fixed-effects estimate is contaminated by 'forbidden' comparisons / negative weights -> Use a heterogeneity-robust estimator (Callaway-Sant'Anna, Borusyak et al., Gardner two-stage); Pre-trend joint test p < 0.05 (or underpowered at 0.10) -> Use sp.sensitivity_rr (Rambachan & Roth honest CI) or switch to sp.callaway_santanna. Alternatives: sp.callaway_santanna, sp.did, sp.honest_did, sp.sun_abraham. Typical minimum N: 100.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yYesOutcome column name.
vceNoStandard-error mode. ``'analytic'`` clusters the Stage-2 residuals (fast) but ignores the variance from estimating the Stage-1 fixed effects and is **anti-conservative** (empirically ~0.78 coverage at a nominal 95% level); a ``UserWarning`` recommends ``'bootstrap'``. ``'bootstrap'`` resamples whole clusters and re-runs the full two-step procedure (Gardner 2021 / ``did2s``), substantially improving coverage (~0.90 vs ~0.78 in simulations; it approaches nominal as the number of clusters grows). Point estimates are identical either way.analytic
timeYesTime column.
alphaNoTwo-sided CI level.
groupYesUnit (panel-id) column.
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
n_bootNoNumber of cluster-bootstrap replications when ``vce='bootstrap'``.
clusterNoCluster variable for Stage-2 SEs. Defaults to ``group``.
horizonNoRelative-time leads/lags to report when ``event_study=True``; defaults to ``range(-5, 6)`` intersected with available support.
controlsNoAdditional covariates included in both stages.
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.
boot_seedNoSeed for the cluster bootstrap (deterministic results).
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://.
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_studyNoIf True, Stage 2 reports coefficients by relative time ``k = t - first_treat_i``.
first_treatYesFirst-treatment-period column. Never-treated units should be encoded as ``0``, ``NaN``, or ``+inf``.
data_columnsNoOptional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads.
data_sample_nNoOptional uniform random subsample size (seed=0, deterministic) — useful on huge panels.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

Annotations only provide readOnlyHint=true and openWorldHint=false. The description goes far beyond that by disclosing statistical assumptions (conditional parallel trends, no anticipation), pre-conditions, typical minimum N, and failure modes with remedial actions. It also warns about anti-conservative standard errors in the vce parameter description, adding transparency about inference quality. All of this enriches the agent's understanding of the tool's behavior without contradicting annotations.

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

Conciseness5/5

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

The description is long but every sentence is substantive: it introduces the estimator, lists assumptions, pre-conditions, failure modes with decision rules, alternatives, and a sample-size heuristic. It is clearly structured with labelled sections (Assumptions, Pre-conditions, Failure modes, Alternatives), and the first sentence immediately identifies the tool. No filler or redundancy; the length is justified by the complexity of the econometric method.

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 (18 parameters, 5 required, output schema present), the description covers the essential context: what the estimator does, when it is valid, what to do if assumptions fail, and which sibling tools to fall back on. It even provides a minimum N heuristic ('Typical minimum N: 100') that is not available elsewhere. The output schema and parameter schema cover the remaining mechanical details, so nothing critical 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 itself does not mention any parameter names or semantics; all parameter-level meaning is carried by the input schema, which is already detailed (e.g., vce explains anti-conservative behavior, bootstrap alternatives; detail explains token payloads). The description adds no extra parameter insight beyond what the schema provides, so a 3 is appropriate.

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 'Gardner (2021) two-stage DID estimator', which names a specific verb–resource pair. It further differentiates itself from siblings by explicitly listing alternatives (sp.callaway_santanna, sp.did, sp.honest_did, sp.sun_abraham) and stating its unique assumptions (heterogeneous effects allowed). An agent can easily distinguish this from other DiD tools without opening schemas.

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 by enumerating failure modes and directing to alternatives: pre-trend violations → honest DiD bounds or covariates; TWFE contamination → heterogeneity-robust estimators; significant pre-trend test → sensitivity_rr or callaway_santanna. It also states pre-conditions (panel/repeated cross-section, never-treated group, pre-treatment periods). This is exactly the 'when/when-not/alternatives' level of guidance.

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