Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

twfe_decomposition

Read-only

Decompose two-way fixed-effects DiD estimates into Goodman-Bacon and de Chaisemartin-D'Haultfoeuille components to detect forbidden comparisons and negative weights, guiding you to heterogeneity-robust alternatives.

Instructions

TWFE decomposition: Goodman-Bacon (2021) + de Chaisemartin-D'Haultfoeuille weights. 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 N: 100.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yYesOutcome variable.
timeYesTime period variable.
alphaNoSignificance level.
groupYesUnit identifier.
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
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.
first_treatYesTreatment timing column (NaN or 0 for 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.9/5.0
Behavior5/5

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

Beyond the readOnlyHint annotation, the description discloses key behavioral traits: the estimator's assumptions, its failure modes (pre-trend violations, forbidden comparisons/negative weights), and typical minimum N. This tells an agent what to expect from the decomposition and how results can be misleading, which annotations alone do not convey.

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 dense but well-structured with labeled sections: definition, assumptions, pre-conditions, failure modes, alternatives, and typical N. Every sentence adds useful information; nothing is redundant with the schema or annotations.

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?

For a complex econometric tool, the description covers purpose, assumptions, data requirements, failure modes, alternative estimators, and a sample-size heuristic. An output schema exists, so the lack of return-value detail is not a gap. The description is complete enough for an agent to decide whether to call it and how to interpret results.

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

Parameters4/5

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

Schema coverage is 100%, so the schema already documents all parameters. The description adds decision-relevant meaning by clarifying data requirements such as 'unit (or group) identifier and a time identifier,' 'never-treated or not-yet-treated comparison group,' and 'pre-treatment periods to assess parallel trends,' which map to group, time, and first_treat.

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 a precise definition: 'TWFE decomposition: Goodman-Bacon (2021) + de Chaisemartin-D'Haultfoeuille weights.' This names the method, the two constituent decompositions, and the resource being analyzed. It also names sibling alternatives, so an agent can distinguish it 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 explicitly lists pre-conditions (panel/repeated cross-section, unit/time identifiers, comparison group, pre-treatment periods) and failure modes that route to alternatives ('Use honest DiD bounds...', 'Use a heterogeneity-robust estimator...'). It names alternatives directly, giving an agent clear when-to-use and when-not-to-use 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