Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

etwfe_emfx

Read-only

Compute aggregated marginal effects from ETWFE staggered DiD fits to estimate average treatment effects, with event-study and calendar-time aggregation options.

Instructions

R etwfe::emfx-style aggregated marginal effects for an ETWFE fit. Validation: certified parity evidence. Assumptions: Conditional parallel trends between treated and comparison groups absent treatment; No anticipation of treatment before its onset; Treatment effects may be heterogeneous across cohorts and time (no homogeneity required). Pre-conditions: Panel or repeated cross-section with a unit (or group) identifier and a time identifier; At least one never-treated or not-yet-treated comparison group; Pre-treatment periods to assess parallel trends. Failure modes: Pre-treatment event-study coefficients are jointly non-zero (pre-trend violation) -> Use honest DiD bounds to quantify robustness to trend violations, or condition on covariates; Two-way fixed-effects estimate is contaminated by 'forbidden' comparisons / negative weights -> Use a heterogeneity-robust estimator (Callaway-Sant'Anna, Borusyak et al., Gardner two-stage). Alternatives: sp.callaway_santanna, sp.did, sp.honest_did. Typical minimum N: 100.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeNoAggregation type.simple
alphaNoSignificance level for confidence intervals.
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
resultYesOutput of :func:`etwfe` or :func:`wooldridge_did`.
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_pathNoAbsolute 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.
weightingNoAggregation weights for cohort-level marginal effects. ``'treated'`` uses the number of treated post-period observations, matching R ``etwfe::emfx(type='simple')`` and Stata ``jwdid, estat simple``. ``'cohort'`` preserves the historical StatsPAI cohort-share weighting.treated
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.
include_leadsNoFor ``type='event'`` and ``type='calendar'``, whether to include pre-treatment relative times (``rel_time < 0``) in the output. These coefficients identify pre-trends and are informative for parallel-trends inspection. Default ``False`` for backward compatibility with earlier versions; set ``True`` for full event-study output matching the R ``etwfe::emfx(type='event')`` default. ``rel_time = -1`` is always the reference category and is excluded.

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?

The description goes far beyond the annotations. It discloses assumptions (parallel trends, no anticipation), pre-conditions (panel structure, comparison groups), failure modes (pre-trend violations, forbidden comparisons), and even typical minimum N. This is rich behavioral context that helps the agent anticipate edge cases. No contradiction with readOnlyHint=true.

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-structured with clear sections (Validation, Assumptions, Pre-conditions, Failure modes, Alternatives, Typical minimum N). Every sentence adds value, and the core purpose is front-loaded. Despite its length, it is not verbose; it efficiently packages essential context for a complex tool.

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 (11 params, output schema, multiple enums), the description is exceptionally complete. It covers assumptions, pre-conditions, failure modes, alternatives, and even suggests typical minimum N. The output schema exists, so return values are already documented, and the description fills the remaining gaps for correct invocation.

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 description coverage is 100%, so all 11 parameters are already documented. The description does not add parameter-specific details beyond the schema, which is acceptable given the high coverage. The description does mention aggregation types in passing but does not elaborate on parameter semantics, so a baseline 3 is appropriate.

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 'aggregated marginal effects for an ETWFE fit,' naming a specific verb and resource. It distinguishes itself from siblings by explicitly listing alternatives like sp.callaway_santanna, sp.did, and sp.honest_did, making its role unambiguous.

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 provides explicit when-to-use guidance via pre-conditions and failure modes. It tells the agent when not to use the tool (e.g., pre-trend violations) and points to specific alternatives, such as honest DiD bounds or heterogeneity-robust estimators. This is exactly what usage guidelines should do.

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