Skip to main content
Glama
vikranthviki

Causal Decision Agent

by vikranthviki

stabilized_weights

Read-only

Calculate stabilized IPTW weights for time-varying treatments to control time-dependent confounding and enable valid causal inference from longitudinal observational data.

Instructions

Compute stabilized IPTW weights for time-varying treatments. Validation: validated evidence tier (known-truth, reference, external-parity, or Monte Carlo artifact). Assumptions: Sequential exchangeability / no unmeasured confounding at each time point; Positivity: every treatment level is possible given the past; Correct specification of the treatment and/or outcome models. Pre-conditions: Sequentially measured covariates, (time-varying) treatment, and outcome; Models for the treatment process and the outcome (or weights). Failure modes: Stabilized weights have extreme values (positivity near-violation) -> Truncate weights, simplify the treatment model, or use a doubly-robust estimator (TMLE). Alternatives: sp.tmle, sp.g_computation, sp.ipw. Typical minimum N: 300.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesUnit and time identifiers.
timeYesUnit and time identifiers.
treatYesTreatment column (binary 0/1 or continuous).
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
baselineNoBaseline covariates.
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.
treat_typeNoOverrides auto-detection.auto
data_columnsNoOptional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads.
time_varyingYesTime-varying confounders (already lagged to pre-treatment).
data_sample_nNoOptional uniform random subsample size (seed=0, deterministic) — useful on huge panels.
trim_per_periodNoIf > 0, trim each period's density ratio at the symmetric quantile ``[trim_per_period, 1 - trim_per_period]`` *before* taking the cumulative product. A common value is 0.01. Set to 0 to disable per-period trimming (the default).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.4/5.0
Behavior5/5

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

Annotations declare readOnlyHint=true and the description is consistent with a compute-only operation. Beyond the annotations, it discloses the causal assumptions, the positivity failure mode with extreme weights, suggested remedies, the validated evidence tier, and a typical minimum sample size. This goes well beyond what the structured annotations provide.

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 organized into labeled sections (Validation, Assumptions, Pre-conditions, Failure modes, Alternatives, Typical minimum N) with no filler. The purpose statement is front-loaded and every subsequent clause carries useful information for deciding whether and how to call the tool.

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?

The description covers what the estimator assumes, what inputs are needed, what can go wrong, and what to do about it, complemented by a complete input schema and an output schema. The only gap is that the 'outcome' and 'models' preconditions are not operationalized against the actual parameter list, so an agent might wonder how those are supplied to the tool.

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%, and the schema already documents all 13 parameters, including trim_per_period, treat_type, and detail. The free-text description adds methodological context and the idea of truncating extreme weights, but it does not provide new parameter-level detail, so it stays at the baseline for high-coverage schemas.

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 first sentence states a specific verb and direct object: 'Compute stabilized IPTW weights for time-varying treatments.' This is not a tautology and clearly differentiates the tool from generic ipw or tmle siblings by naming the stabilized-weight variant and the time-varying scope. The alternatives line reinforces identity without requiring the reader to inspect the schema.

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 provides clear preconditions (sequentially measured covariates, treatment, models), assumptions (exchangeability, positivity), and a failure-mode remediation path (truncate weights or use TMLE). It names alternatives, but it does not give explicit decision rules for when to choose sp.tmle vs. sp.g_computation vs. sp.ipw over this tool, so there is clear context but not an exhaustive selection guide.

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