interflex
Estimate how a treatment's effect varies across a moderator using binning, linear, or kernel models, with diagnostic tests for valid inference.
Instructions
Conditional marginal effects of d across a moderator x Validation: certified parity evidence.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| d | Yes | Outcome, treatment (binary 0/1 or continuous) and moderator. | |
| x | Yes | Outcome, treatment (binary 0/1 or continuous) and moderator. | |
| y | Yes | Outcome, treatment (binary 0/1 or continuous) and moderator. | |
| z | No | Additional covariates entering linearly. | |
| bw | No | Kernel bandwidth on the moderator's scale (before the adaptive density scaling). Required for ``estimator='kernel'``; interflex's cross-validated choice is not ported. | |
| vce | No | Variance construction. ``'robust'`` is the HC1 sandwich (interflex's default) and ``'homoscedastic'`` the classical covariance for the linear and binning models and the Wald test; ``'bootstrap'`` (kernel estimator only) draws nonparametric bootstrap standard errors, the linear and binning estimators always reporting delta-method SEs. | robust |
| seed | No | Bootstrap replications and seed. | |
| wald | No | Report the Wald and LR tests of the linear interaction against the binning model (``estimator='binning'`` or ``'linear'``). | |
| alpha | No | Significance level for confidence intervals and tests. | |
| nbins | No | Number of moderator bins (cut at sample quantiles) for the binning estimator; ``cutoffs`` overrides the quantiles. | |
| neval | No | Evaluation points, equally spaced over the moderator's range. | |
| 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 |
| n_boot | No | Bootstrap replications and seed. | |
| x_eval | No | Explicit evaluation points. | |
| cutoffs | No | cutoffs parameter (Optional[Sequence[float]]). | |
| weights | No | Observation weights column. | |
| adaptive | No | Kernel estimator only. ``True`` scales the bandwidth at each evaluation point by the moderator's density as the R package does (``h(x) = bw * sqrt(geometric-mean density / density(x))``); ``False`` uses the fixed Gaussian kernel ``phi((X - x)/bw)`` of the Stata ``interflex`` command. | |
| 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. | |
| 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://. | |
| estimator | No | estimator parameter (str). | binning |
| 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. | |
| wald_test | No | Reference distribution of the Wald statistic: chi-square (R ``lmtest::waldtest(test = "Chisq")``) or the F distribution with the full model's residual degrees of freedom (Stata interflex). | chisq |
| treat_type | No | Inferred from ``d`` when omitted (two distinct values = discrete). | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. | |
| wald_full_moderate | No | Whether the fully interacted model behind the Wald / LR tests also interacts the covariates ``z`` with the bins (R interflex). The Stata command leaves the covariates uninteracted; set ``False`` to reproduce its test. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||