ltmle
Estimate causal contrasts of static treatment regimes over time, controlling for time-varying confounding with double-robust TMLE inference.
Instructions
Longitudinal TMLE for static regime contrasts. Validation: validated evidence tier (known-truth, reference, external-parity, or Monte Carlo artifact). Assumptions: Sequential exchangeability (no unmeasured time-varying confounding) at every treatment time point; Positivity at each time point conditional on the past; Correctly specified outcome (Q) and treatment (g) models, though TMLE is doubly robust to one of them. Pre-conditions: Long-format data with time-varying treatment, confounders and the static regime contrast of interest. Failure modes: Near-positivity violation: estimated treatment probabilities approach 0 or 1, inflating variance -> Bound (truncate) the cumulative weights or use a marginal structural model with stabilised weights. Alternatives: sp.tmle, sp.g_computation, sp.msm. Typical minimum N: 500.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Final outcome column. | |
| alpha | No | Significance level for confidence intervals and tests. | |
| detail | No | Payload 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 |
| baseline | No | Baseline time-invariant covariates. | |
| as_handle | No | If 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. | |
| censoring | No | Censoring indicator column per time point (``1=observed``, ``0=censored``). If None, no censoring is modeled. | |
| data_path | Yes | Absolute 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_id | No | Optional 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. | |
| treatments | Yes | Treatment column per time point, length ``K``. | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| outcome_type | No | ``auto`` detects from unique values of ``y``. | auto |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. | |
| regime_control | No | Regimes to contrast. Default: all-1 vs all-0. A regime may also be a **callable** ``regime(k, history)`` for *dynamic regimes* that depend on the simulated / observed history of baseline and time-varying covariates. The callable receives ``k`` (int 0..K-1) and ``history`` -- a dict mapping column name to the length-``n`` numpy array observed up to that timepoint -- and must return a length-``n`` numpy array of 0/1 treatment assignments. | |
| regime_treated | No | Regimes to contrast. Default: all-1 vs all-0. A regime may also be a **callable** ``regime(k, history)`` for *dynamic regimes* that depend on the simulated / observed history of baseline and time-varying covariates. The callable receives ``k`` (int 0..K-1) and ``history`` -- a dict mapping column name to the length-``n`` numpy array observed up to that timepoint -- and must return a length-``n`` numpy array of 0/1 treatment assignments. | |
| covariates_time | Yes | ``covariates_time[k]`` lists time-k covariate columns (may be empty). Length ``K``. | |
| propensity_bounds | No | Clip propensity to this range for stability. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||