model_averaging_dml
Estimate causal effects with double machine learning by stacking multiple candidate nuisance learners, reducing sensitivity to any single model and yielding robust treatment-effect estimates with cross-fitting.
Instructions
Model-averaging / stacking DML-PLR estimator. Validation: validated evidence tier (known-truth, reference, external-parity, or Monte Carlo artifact).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| y | Yes | Outcome column. | |
| seed | No | Random seed for reproducible stochastic steps. | |
| alpha | No | Two-sided CI level. | |
| treat | Yes | Continuous-or-binary treatment column. | |
| 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_folds | No | Cross-fitting folds per candidate. | |
| 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://. | |
| 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. | |
| candidates | No | Candidate nuisance learners. ``ml_g`` regresses ``y`` on ``X``; ``ml_m`` regresses ``treat`` on ``X``. Defaults to a Lasso/Ridge/ RandomForest/GradientBoosting roster. | |
| covariates | Yes | Covariate columns ``X``. | |
| weight_rule | No | How to combine candidate nuisance predictions or estimates. * ``"short_stacking"`` *(default; Ahrens et al. 2025 eq. 7)* -- solve constrained least squares on cross-fitted predictions for each nuisance separately (``y`` and ``D``), produce stacked nuisances, plug into the PLR moment equation. * ``"single_best"`` -- Ahrens et al. (2025, fn. 8): pick the candidate with lowest joint nuisance MSE. * ``"inverse_risk"`` -- :math:`w_k \propto 1/(\text{MSE}_g + \text{MSE}_m)`. Convenience baseline; **not** in the paper. * ``"equal"`` -- :math:`w_k = 1/K`. Convenience baseline; **not** in the paper. For the non-stacking rules (``inverse_risk`` / ``equal`` / ``single_best``) the function computes per-candidate :math:`\hat\theta_k` and reports the weighted average with a between-candidate-covariance-corrected SE; for ``"short_stacking"`` it reports the standard PLR sandwich SE on the stacked-nuisance score (Neyman orthogonality is preserved). | short_stacking |
| 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. | |
| sample_weight | No | Per-observation weights. If supplied, every nuisance fit uses ``sample_weight=`` (with a graceful fallback warning if the learner does not accept it), the CLS stacking objective becomes weighted least squares, and the PLR moment + sandwich variance use weighted sums. The MSE used for ``inverse_risk`` / ``single_best`` weighting is also the weighted MSE. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||