Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

ddd_heterogeneous

Read-only

Estimates heterogeneity-robust triple-differences for staggered adoption, decomposing effects by cohort and time with an unaffected subgroup as placebo to avoid negative-weight biases.

Instructions

Heterogeneity-robust triple differences (DDD) for staggered adoption. Decomposes DDD into per-(cohort, time) cells via a Callaway-Sant'Anna-style aggregation, with the unaffected subgroup's DID as a placebo. Avoids the negative-weight issue that textbook TWFE DDD inherits from TWFE DID (Goodman-Bacon 2021 analogue). Validation: certified evidence with scoped limitations. Known limitations: the placebo joint test is only produced on the bootstrap path; se='analytic' reports None for it, because that test needs the joint covariance of the placebo arms rather than of the DDD; control_group='notyettreated' is only partially comparable to triplediff 0.2.4: its per-control-cohort estimates agree exactly, but the reference misindexes the influence functions it combines, so the combined numbers differ by convention on cells where the comparison does not span the whole panel; the aggregation convention differs from triplediff::agg_ddd(type='simple'): the default weights cohorts by treated-eligible units; pass weight_by='cohort' to match the R package. Assumptions: Parallel trends relaxed to: same differential trend across treated vs never-treated, within both affected and unaffected subgro...

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xNoBase-period covariates; identification becomes CONDITIONAL DDD parallel trends
yYesOutcome variable column name or outcome array.
seNo'analytic' influence-function variance (exact, and what triplediff reports) or 'bootstrap' clustered on unit (the only path that fills in placebo_joint_test). Defaults to bootstrap without covariates, analytic with them
seedNoRandom seed for reproducible stochastic steps.
timeYesTime period column.
unitYesUnit identifier column.
alphaNoSignificance level for confidence intervals and tests.
cohortYesFirst-treatment period (never_value = never-treated)
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_bootNoNumber of bootstrap replications.
subgroupYesBinary within-group subgroup indicator (1=affected, 0=placebo)
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.
weight_byNoAggregation weights: 'eligible' (treated units in the affected subgroup) or 'cohort' (whole cohort, both subgroups -- reproduces triplediff::agg_ddd)eligible
est_methodNoNuisance combination: doubly robust, inverse probability weighting, or outcome regressiondr
never_valueNoValue in cohort for never-treated units
data_columnsNoOptional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads.
control_groupNoControl units: never-treated, or not-yet-treated cohorts combined by minimum distance (see the docstring warning -- that path deliberately diverges from triplediff 0.2.4, which misindexes its influence functions there)nevertreated
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 declare readOnlyHint=true and openWorldHint=false. The description adds substantial context on known limitations, including placebo test availability and differences from triplediff. It does not contradict annotations, and it adds value beyond the schema by detailing edge cases.

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 information-dense but long and somewhat unstructured. It front-loads the main purpose well, but then goes into a long list of limitations and comparisons that could be better organized. Every sentence adds value, but the density may overwhelm an agent.

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?

Given the tool's complexity (20 parameters, 6 required, multiple enums, output schema present), the description covers the key methodological nuance, the placebo test behavior, and the differences from R. The description is complete enough for an agent to understand the tool's role and call it correctly, though it assumes prior knowledge of DDD.

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?

The input schema provides descriptions for all 20 parameters (100% coverage), so the baseline is 3. The tool description adds meaning by explaining how parameters like weight_by and control_group affect behavior and when they matter, which is not in the schema. It provides normative guidance on defaults and by mentioning conditional DDD for x.

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 computes heterogeneity-robust triple differences (DDD) for staggered adoption, breaking it into per-cohort-time cells and using a placebo test. It distinguishes itself from textbook TWFE DDD, and the title and siblings (ddd, aggte) suggest this is a specialized variant.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains when to use this tool (for heterogeneity-robust DDD in staggered adoption) and contrasts with TWFE DDD plus the R package triplediff. It gives a specific alternative (weight_by='cohort' to match R), but does not explicitly mention when NOT to use it or which sibling tools to choose over it.

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