Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

did_timevarying_covariates

Read-only

Estimate difference-in-differences treatment effects in staggered adoption by freezing time-varying covariates at baseline, preventing bad-controls bias when treatment affects covariates.

Instructions

DiD with time-varying covariates frozen at baseline (Caetano, Callaway, Payne & Rodrigues 2022 [pending verification]). Avoids the bad-controls bias that arises when treatment affects the covariates: freezes X at period g + baseline_offset (default g-1) per cohort and uses the frozen values as controls in a per-(g, t) outcome-regression DiD. Aggregates via cohort-size weights. Assumptions: Conditional parallel trends given frozen baseline X; No anticipation; SUTVA. Pre-conditions: staggered adoption with >= 1 never-treated unit; covariates column(s) exist for the baseline period per cohort; integer-valued time column. Failure modes: No observation at baseline period for some units -> Fallback uses the first observed period; review detail coverage; Covariate measured with error or missing -> Impute (sp.mice_impute) or restrict to a complete sub-sample before calling; 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. Alternatives: sp.callaway_santanna, sp.drdid, sp.wooldridge_did, sp.sun_abraham. Typical minimum N: 150.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yYesOutcome variable column name or outcome array.
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.
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.
covariatesYesTime-varying covariates to freeze at baseline
never_valueNonever_value parameter.
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.
baseline_offsetNoOffset relative to first-treatment period for freezing

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare readOnlyHint=true, so no contradiction. The description adds substantial behavioral context beyond the annotations: it explains that covariates are frozen at baseline per cohort, describes the aggregation via cohort-size weights, discloses failure modes and fallback behavior when baseline observations are missing, and warns about covariate measurement error. This goes far beyond what the annotations reveal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but dense and well-structured, front-loading the core mechanism before moving to assumptions, pre-conditions, failure modes, and alternatives. Every section earns its place given the tool's complexity, though the 'pending verification' citation and typical minimum N are minor extras that could be trimmed without losing essential guidance.

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 econometric estimator, the description covers the identification strategy, assumptions, pre-conditions, failure modes with fallback behavior, suggested remedies, alternative tools, and a sample-size guideline. Combined with the output schema and full parameter documentation, this is complete enough for an agent to decide when to call the tool and how to handle common failures.

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 description coverage is 100%, so the schema already documents all parameters. The description nonetheless adds meaning for the key parameters: covariates and baseline_offset are explained through the formula 'freezes X at period g + baseline_offset (default g-1)', which clarifies their joint behavior beyond the schema field descriptions. Generic parameters like data_path and seed do not need further elaboration.

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 names a specific estimator ('DiD with time-varying covariates frozen at baseline'), states the exact resource it acts on, and distinguishes it from siblings by naming alternatives like sp.callaway_santanna and sp.sun_abraham. It is immediately clear what this tool does and how it differs from related DiD tools.

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: it names the bad-controls problem motivating the method, lists pre-conditions such as staggered adoption and never-treated units, and gives failure-mode-specific actions such as using sp.mice_impute for missing covariates or sp.sensitivity_rr for pre-trend violations. It also enumerates alternative tools, making selection guidance concrete and actionable.

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