Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

drdid

Read-only

Estimate 2x2 difference-in-differences causal effects with covariates using a doubly-robust combination of outcome regression and inverse probability weighting; consistent if either nuisance model is correct.

Instructions

Doubly-robust DiD (Sant'Anna & Zhao 2020). Combines outcome regression with IPW; consistent if either model is correct. Primary estimator for 2x2 DiD with covariates. Validation: certified parity evidence. Assumptions: Conditional parallel trends given X; Overlap / positivity: 0 < P(D=1|X) < 1; Correct specification of at least one nuisance model. Pre-conditions: panel or repeated cross-section with 2 periods; group is a binary unit-level treatment indicator; covariates have non-zero variance and overlap. Failure modes: Propensity score near 0/1 (overlap violation) -> Trim extreme propensity scores or use sp.ipw_trim. Alternatives: sp.did_2x2, sp.callaway_santanna, sp.wooldridge_did. Typical minimum N: 100.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yYesOutcome variable
idNoUnit identifier for true two-period panel DR-DID
seedNoRandom seed for reproducible stochastic steps.
timeYesTime period column
alphaNoSignificance level for confidence intervals and tests.
groupYesUnit-level treatment 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
methodNoNuisance estimators for est_method='dr' (R DRDID::drdid(estMethod=)): 'imp' uses inverse probability tilting + odds-weighted least squares so the DR moment is Neyman-orthogonal by construction; 'trad' uses plain logit + OLS with the estimation effects propagated. Ignored unless est_method='dr'.imp
n_bootNoDeprecated / inert: standard errors come from the Sant'Anna-Zhao influence function on every path.
weightsNoObservation weights column (R DRDID i.weights), renormalised to mean one.
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 X
est_methodNoEstimator family. With method/normalized/locally_efficient and id=, this reaches all 14 R DRDID 1.2.3 estimators: dr -> drdid_[imp_]panel / drdid_[imp_]rc[1]; ipw -> [std_]ipw_did_panel|rc; reg -> reg_did_panel|rc; twfe -> twfe_did_panel|rc. 'twfe' is for comparison, not recommendation: with covariates it is the specification Sant'Anna-Zhao and Caetano-Callaway warn about.dr
normalizedNoest_method='ipw' only. True = Hajek-normalised (std_ipw_did_*), control arm divided by its own weight mass. False = Abadie (2005) (ipw_did_*), both arms sharing the denominator E[D].
trim_levelNoDrop control units whose propensity score reaches this cutoff (DRDID trim.level). 1.0 disables.
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.
locally_efficientNoest_method='dr' on repeated cross-sections only. False drops the semiparametric-efficiency terms, giving drdid_rc1 / drdid_imp_rc1, which avoid fitting outcome regressions on the treated cells. Both are consistent.

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 already declare readOnlyHint=true, and the description does not contradict this. It goes beyond annotations by detailing assumptions (conditional parallel trends, overlap, correct nuisance model), failure modes, and validation status. This provides comprehensive behavioral context for an estimation tool.

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 well-organized into labeled sections (Assumptions, Pre-conditions, Failure modes, Alternatives, Typical minimum N), front-loads the core purpose, and every sentence contributes meaningful information. No fluff or redundancy.

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 (20 parameters, 4 required) and the existence of an output schema, the description covers all necessary operational context: assumptions, preconditions, failure modes, alternatives, and even sample size guidance. Nothing critical is missing for correct usage.

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 coverage is 100%, so parameters are already well-documented. The description adds marginal context like 'combines outcome regression with IPW' which hints at the estimation method, but does not elaborate on parameter-specific behavior beyond what the schema provides. This meets the baseline for high schema coverage.

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 states the tool performs doubly-robust DiD (Sant'Anna & Zhao 2020) combining outcome regression with IPW, and explicitly identifies it as the primary estimator for 2x2 DiD with covariates. It also names specific alternatives, distinguishing it from sibling tools like did_2x2, callaway_santanna, and wooldridge_did.

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?

Provides explicit pre-conditions (panel or repeated cross-section with 2 periods, binary treatment indicator, covariates with variance and overlap) and failure modes with remedies (trimming extreme propensity scores or using ipw_trim). Also lists alternative tools for different scenarios, giving 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