Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

did_2x2

Read-only

Estimate causal treatment effects with a two-group, two-period difference-in-differences design. Compares pre/post changes between treated and control units via differencing or OLS, with optional covariates and robust/cluster SEs.

Instructions

Canonical 2x2 DID: two groups (treated / control) x two periods (pre / post). Point estimate via either group-means differencing or OLS on the treat x post interaction; optional covariates, robust / cluster SE, and sample weights. Validation: certified parity evidence. Do NOT use when: treatment timing is staggered across units -- the TWFE 2x2 estimate is a negative-weighted mix (Goodman-Bacon 2021); use sp.callaway_santanna, sp.sun_abraham or sp.did_imputation. Assumptions: Parallel trends; No anticipation; SUTVA (no spillovers). Pre-conditions: data has exactly two time periods (pre, post); treat is 0/1 constant within unit (unit-level, not time-varying); at least a handful of treated and control units. Failure modes: Staggered timing (> 2 periods with varying treat start) -> Use sp.callaway_santanna / sp.sun_abraham / sp.did_imputation; Very few clusters at the group level -> Use wild cluster bootstrap via sp.wild_cluster_bootstrap; 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.drdid, sp.did_analysis, sp.callaway_santanna, sp.sun_abraham. Typical minimum N: 30.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yYesOutcome variable
timeYesTime / period indicator
alphaNoSignificance level for confidence intervals and tests.
treatYesBinary treatment-group indicator (0/1)
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
robustNoHeteroskedasticity-robust SE when no cluster provided
clusterNoColumn for cluster-robust SE (defaults to treat)
weightsNoOptional column name for sampling weights
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.
covariatesNoCovariates included additively; for DR use sp.drdid
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.8/5.0
Behavior5/5

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

With readOnlyHint=true already covering the safety profile, the description goes beyond annotations by disclosing estimator mechanics, assumptions (parallel trends, no anticipation, SUTVA), and failure modes such as negative-weighted TWFE mixes in staggered designs. It also adds 'Validation: certified parity evidence' as an extra behavioral signal without contradicting the annotation.

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 text is front-loaded with the core definition and sectioned for skimmability, but it is long and contains some redundancy — the staggered-timing exclusion and the same alternatives appear in both the 'Do NOT use' block and the 'Failure modes' section. Still, nearly every clause carries diagnostic value.

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?

The definition covers purpose, exclusions, assumptions, preconditions, failure-mode routing, alternatives, and sample-size guidance, and an output schema exists so return values do not need to be explained in prose. For a 2x2 DID tool embedded in a large sibling family, this is complete enough for an agent to decide and invoke correctly.

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 description coverage is 100%, so the baseline is 3; the description adds meaningful method-level semantics by requiring exactly two periods, a unit-constant 0/1 treat, and by summarizing covariates, robust/cluster SE, and weights. It does not enumerate every parameter, but the schema already handles that burden.

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 specifies a precise estimator — 'Canonical 2x2 DID: two groups (treated/control) x two periods (pre/post)' — and details how the point estimate is computed via group-means differencing or OLS on the treat x post interaction. It also distinguishes itself from siblings by explicitly rejecting staggered-timing designs and naming the alternatives.

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 conditions ('exactly two time periods', unit-level 0/1 treat) and explicit when-not-to-use conditions with named replacements for staggered timing, few clusters, and pre-trend failures. It also lists alternatives and a typical minimum N, leaving little to inference.

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