Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

did_misclassified

Read-only

Adjust staggered difference-in-differences estimates for misclassified treatment timing and anticipation, using a supplied misclassification probability to produce robust causal effects.

Instructions

Staggered DiD robust to treatment-timing misclassification and anticipation. Adjusts the CS-style aggregation for a user-supplied misclassification probability pi_misclass and a known anticipation horizon. Use when first-treat dates are noisy (e.g., survey-reported). Assumptions: Parallel trends: treated and control groups would have followed the same trajectory absent treatment; No anticipation: outcomes in pre-treatment periods are unaffected by future treatment; SUTVA: no spillovers between units. Pre-conditions: pi_misclass is between 0 and 0.5 (else identification flips); Known anticipation horizon; data is panel or repeated cross-section with a time column. Failure modes: 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; Staggered treatment timing with TWFE method -> TWFE can give negative weights; use Callaway-Sant'Anna, Sun-Abraham, or BJS imputation; Pre-trend test underpowered (Roth 2022) -> Check sp.pretrends_power -- if low, report honest CI via sp.sensitivity_rr. Alternatives: sp.callaway_santanna, sp.sun_abraham, sp.did_imputation, sp.sdid. Typical minimum N: 200.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yYesOutcome variable column name or outcome array.
idYesUnit, subject, or panel identifier column.
timeYesTime period column.
alphaNoSignificance level for confidence intervals and tests.
treatYesFirst-treatment period (possibly noisy)
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.
pi_misclassNoP(observed treat != true treat) -- between 0 and 1
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.
anticipation_periodsNoanticipation_periods parameter (int).

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?

The description discloses assumptions (parallel trends, no anticipation, SUTVA), pre-conditions (pi_misclass range, anticipation horizon), and failure modes (pre-trend test results, TWFE issues). This goes far beyond the minimal annotations (readOnlyHint, openWorldHint), which only indicate non-mutating behavior. No contradiction with annotations.

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?

Though long, it is efficiently structured: purpose, when to use, assumptions, pre-conditions, failure modes, alternatives, typical N. Every sentence adds value and the critical info is front-loaded. No fluff.

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 tool with 14 params, 5 required, and an output schema, the description covers the use case, data requirements, assumptions, failure modes, and fallbacks. It also provides typical minimum N. The output schema covers return format, so nothing essential is missing.

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 has 100% coverage, so baseline is 3. The description adds crucial context for pi_misclass (range 0-0.5) and anticipation_periods, and explains their role in the method. While it doesn't detail every parameter, it enriches the key ones beyond schema 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?

Clearly states it is a Staggered DiD robust to misclassification and anticipation, adjusting CS-style aggregation. It specifies the exact resource and method, and distinguishes itself from generic DiD tools by its niche. The description names alternatives, so an agent can differentiate it from siblings like callaway_santanna or sun_abraham.

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?

Explicitly states 'Use when first-treat dates are noisy' and provides failure-mode routing (e.g., switch to sensitivity_rr or callaway_santanna). It also lists explicit alternatives, giving the agent clear decision rules for when to choose this tool vs others.

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