Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

gardner_did

Read-only

Run two-stage difference-in-differences to estimate treatment effects or event-study coefficients from panel data, residualizing outcomes with fixed effects from untreated observations to avoid bias from heterogeneous timing.

Instructions

Gardner (2021) two-stage DID. Stage-1 fits two-way FEs on untreated observations; Stage-2 regresses the residualised outcome on treatment dummies (ATT or event study). Numerically close to Borusyak-Jaravel-Spiess imputation with unit-clustered SEs. Validation: certified parity evidence. 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). Alternatives: sp.callaway_santanna, sp.did, sp.honest_did. Typical minimum...

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yYesOutcome column
timeYesTime column
alphaNoSignificance level for confidence intervals and tests.
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
clusterNoCluster variable for Stage-2 SEs (defaults to group)
horizonNoRelative-time leads/lags to report (default range(-5, 6))
controlsNoAdditional covariates
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://.
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, report coefficients by relative time k = t - first_treat
first_treatYesFirst-treatment-period column; 0/NaN/inf = never treated
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.2/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, and the description does not contradict that. Beyond the annotations, it discloses the internal procedure (residualization, two-stage estimation), the validation status ('certified parity evidence'), and important model assumptions that affect result interpretation. This adds meaningful context not available from annotations alone, though it does not discuss side effects like caching or resource usage.

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

Conciseness3/5

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

The description is well-structured into sections (Assumptions, Pre-conditions, Failure modes, Alternatives) and packs substantial information, but it is long and ends abruptly mid-sentence ('Typical minimum...'), which suggests incomplete drafting. While the density is justifiable for a complex estimator, the truncation hurts readability and compactness.

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

Completeness4/5

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

For a complex econometric tool with an output schema, the description covers method, use cases, assumptions, failure modes, and alternatives comprehensively. The only notable gap is the truncated final sentence and a lack of mention of parameter interactions (e.g., event_study vs ATT), but those are already defined in the input schema. Overall, an agent has enough context to call this tool correctly.

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 parameters are fully documented elsewhere. The description adds pre-condition context (e.g., panel structure, never-treated group) that indirectly informs parameter choice, but it does not directly elaborate on any specific parameter beyond the schema. This matches the baseline for high schema coverage with modest descriptive additions.

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 clearly identifies the estimator ('Gardner (2021) two-stage DID'), explains the two stages, and differentiates it from siblings by noting it is 'numerically close to Borusyak-Jaravel-Spiess imputation' and listing explicit alternatives. An agent can understand exactly what this tool computes and how it differs from related estimators.

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 provides explicit pre-conditions, failure modes, and actionable alternatives. It tells the agent when to use this tool (e.g., for heterogeneous treatment effects) and when to switch (e.g., pre-trend violation -> honest_did; negative weights -> heterogeneity-robust estimators). It names specific sibling tools as alternatives, leaving no ambiguity about selection.

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