Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

cohort_anchored_event_study

Read-only

Avoids cohort contamination in staggered adoption studies by estimating separate event-study paths per cohort and aggregating with cohort weights for cluster-robust treatment effects.

Instructions

Cohort-anchored event study. Instead of averaging across cohorts at each relative-time bin (which can contaminate leads / lags with other cohorts' dynamics), estimates separate event-study paths per cohort and then aggregates with cohort weights. Standard errors are cluster-robust and carry no protection against parallel-trends violations: this is the cohort-anchored estimator Liu (2025) starts from, NOT that paper's block-bias robust-inference procedure, which is not implemented. For parallel-trends sensitivity use sp.honest_did. Assumptions: Parallel trends hold within each treatment cohort relative to never-treated units (cohort-anchored, not pooled TWFE); No anticipation: outcomes in pre-event periods unaffected by future treatment; Treatment is an absorbing first-treatment event (staggered adoption, treat encodes first period, 0 = never-treated). Pre-conditions: Long-format balanced/unbalanced panel with id and time columns; treat column gives first-treatment period per unit (0 = never-treated), with at least one never-treated cohort; Enough pre/post periods to fill the requested leads/lags event-time window. Failure modes: All units treated in same period / no never-treated...

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yYesOutcome variable column name or outcome array.
idYesUnit, subject, or panel identifier column.
lagsNolags parameter (int).
timeYesTime period column.
alphaNoSignificance level for confidence intervals and tests.
leadsNoleads parameter (int).
treatYesTreatment indicator or first-treatment-period column.
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
clusterNoCluster identifier column for clustered standard errors.
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.
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 details: cluster-robust standard errors with no parallel-trends protection, cohort-anchored rather than pooled TWFE identification, and explicit assumptions such as no anticipation and absorbing treatment. It also lists failure modes, giving the agent useful information about when results will be invalid.

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 organized into purpose, contrast with alternatives, assumptions, pre-conditions, and failure modes. Every section adds actionable information, and the core purpose is front-loaded before the assumptions and constraints.

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 estimator's complexity and the crowded event-study sibling space, the description covers what the tool does, what it is not, when to use an alternative, assumptions, data pre-conditions, and failure modes. The output schema exists, so return-value description is not required, and the input schema covers parameters.

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?

Input schema coverage is 100%, so the baseline is 3, but the description adds real parameter meaning: it clarifies that treat encodes the first treatment period with 0 = never-treated, that id and time define a long-format panel, and that leads/lags define a requested event-time window. This goes beyond the schema's generic descriptions.

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 the specific estimator name and explains exactly what it computes: separate event-study paths per cohort aggregated with cohort weights, explicitly contrasted with averaging across cohorts at each relative-time bin. It distinguishes itself from Liu (2025)'s robust-inference procedure and from honest_did, so an agent can differentiate it 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?

The description gives explicit when/when-not guidance: it is the cohort-anchored starting estimator, not the block-bias robust-inference procedure, and for parallel-trends sensitivity the agent should use sp.honest_did. Assumptions and pre-conditions further constrain when the tool is appropriate, including never-treated cohorts and absorbing first-treatment events.

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