Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

did_multiplegt

Read-only

Estimates causal effects of a binary treatment that can switch on and off in panel data, using consecutive-period DID that compares switchers to stayers. Supports placebo lags, dynamic horizons, and cluster bootstrap.

Instructions

de Chaisemartin & D'Haultfuille (2020) DID_M estimator. Weighted average of consecutive-period DID cells where treatment 'switchers' are compared to 'stayers'. Handles treatments that switch on AND off (unlike Callaway-Sant'Anna which assumes staggered adoption). Supports placebo lags, dynamic horizons, cluster bootstrap SE, joint placebo test and average-cumulative-effect summary from dCDH (2024). The heteroskedastic-weights variant and full dCDH (2024) intertemporal event-study (did_multiplegt_dyn Stata) are on the roadmap -- see docs/rfc/multiplegt_dyn.md. Validation: certified parity evidence. Assumptions: Parallel trends between switchers and stayers; Stable treatment effects across consecutive periods (for the DID_M weighted average interpretation); No anticipation. Pre-conditions: long-format panel with one row per unit x period; treatment is binary (0/1) and may vary over time within a unit; at least two periods observed per unit so a first difference can be computed. Failure modes: No switching cells (nobody changes treatment) -> did_multiplegt identifies effects only from treatment switches. Fall back to callaway_santanna if the design is staggered adoption; Joint placeb...

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yYesOutcome variable
seedNoRandom seed for reproducible stochastic steps.
timeYesTime period column
alphaNoSignificance level for confidence intervals and tests.
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
n_bootNoCluster-bootstrap replications
clusterNoCluster variable for bootstrap (defaults to group)
dynamicNoNumber of post-treatment dynamic horizons
placeboNoNumber of pre-treatment placebo lags
controlsNoControls residualised via first differences
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.
treatmentYesBinary current-treatment indicator (may switch on and off)
data_columnsNoOptional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads.
placebo_signNoPlacebo sign convention. dCDH's own Stata and R packages disagree: on did::mpdta both give |placebo_1| = 0.024269 with identical effects, but opposite signs. Default keeps Stata'sstata
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?

Annotations only declare readOnlyHint=true and openWorldHint=false; the description adds substantial behavioral context: assumptions (parallel trends, stable effects, no anticipation), preconditions on data structure, failure modes when nobody switches treatment, and the limitation that switching both on and off is handled. It also flags roadmap items and validation evidence, exceeding what annotations alone provide.

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 long but organized with labeled sections (assumptions, pre-conditions, failure modes, validation). All information is relevant, though the truncation at 'Joint placeb...' and the roadmap detour add slight noise. It is front-loaded with the estimator definition and remains scannable.

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 estimator with 18 parameters, an output schema, and read-only hints, the description covers the estimator's mechanics, scope, assumptions, prerequisites, failure modes, and alternatives. The output schema covers return values, and the schema covers parameter details, so the description completes the contextual picture without redundant repetition.

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 baseline is 3. The description adds value by clarifying the treatment variable must be binary and time-varying, requiring a long-format panel with at least two periods per unit, and by explaining that placebo/dynamic/boostrap features are supported. This goes beyond the schema's bare parameter descriptions without duplicating them.

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 names a specific estimator (DID_M), gives the intuition as a weighted average of consecutive-period DID cells comparing switchers to stayers, and explicitly differentiates it from Callaway-Sant'Anna. An agent can immediately identify what this tool computes and how it differs from closely related siblings.

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?

It states when the estimator is appropriate: treatments that switch on and off, and explicitly says to fall back to callaway_santanna for staggered-adoption designs. Pre-conditions (long panel, binary treatment, ≥2 periods) and failure modes (no switching cells) give clear guidance on when this tool should and should not be used.

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