causalis.scenarios.unconfoundedness.model.IRMIRM
Bases: sklearn.base.BaseEstimator
Interactive Regression Model (IRM) with cross-fitting using CausalData.
Parameters
- dataCausalData
Data container with outcome, binary treatment (0/1), and confounders.
- ml_gestimator
Learner for E[Y|X,D]. If classifier and Y is binary, predict_proba is used; otherwise predict().
- ml_mclassifier
Learner for E[D|X] (propensity). Must support predict_proba() or predict() in (0,1).
- n_foldsint, default 5
Number of cross-fitting folds.
- n_repint, default 1
Number of repetitions of sample splitting. Currently only 1 is supported.
- normalize_ipwbool, default False
Whether to normalize IPW terms within the score. Applied to ATE only. For ATTE, normalization is ignored to preserve the canonical ATTE EIF.
- trimming_rule{“truncate”}, default “truncate”
Trimming approach for propensity scores.
- trimming_thresholdfloat, default 1e-2
Threshold for trimming if rule is “truncate”.
- weightsOptional[np.ndarray or Dict], default None
Optional weights. - If array of shape (n,), used as ATE weights (w). Assumed E[w|X] = w. - If dict, can contain ‘weights’ (w) and ‘weights_bar’ (E[w|X]). - For ATTE, computed internally (w=D/P(D=1), w_bar=m(X)/P(D=1)). Note: If weights depend on treatment or outcome, E[w|X] must be provided for correct sensitivity analysis.
- relative_baseline_minfloat, default 1e-8
Minimum absolute baseline value used for relative effects. If |mu_c| is below this threshold, relative estimates are set to NaN with a warning.
- random_stateOptional[int], default None
Random seed for fold creation.
- n_jobsint, default 1
Number of parallel jobs for fold-level cross-fitting. Use
-1to use all available CPUs. Practical guidance: - Start withn_jobs=1for stable, low-contention defaults. - Increase ton_jobs=2/4/-1when cross-fitting is the bottleneck. - If nuisance learners are already multithreaded (e.g. CatBoost withthread_count=-1), keepn_jobs=1or set learner threads to1to avoid CPU oversubscription. - On shared machines, prefer a bounded value (for example2or4) instead of-1.- store_diagnosticsbool, default True
Whether to retain raw fit-time arrays and diagnostic-only artifacts on the fitted model. Set to
Falsefor a lighter-weight estimator that still supports effect estimation, while only retaining immutable outcome and treatment snapshots. In lightweight mode the estimator no longer keeps the confounder matrix, raw propensities, or fold assignments in memory afterfit().
Examples
Notes
The IRM model targets binary-treatment causal effects under unconfoundedness. Let with and define
Under conditional ignorability and overlap,
the target functionals are identified as
and
This implementation cross-fits three nuisance objects: , , and . Propensities are trimmed via
where trimming_threshold.
Estimation solves the sample moment equation
giving the closed-form estimator
For both ATE and ATTE, the orthogonal score component used here is
The score derivative differs by estimand:
The corresponding weights are
while for ATTE` this implementation uses normalized treated weights
If normalize_ipw=True, the inverse-probability factors
and are additionally
stabilized by their sample means (a Hajek-style normalization). This option
is applied to ATE only; for ATTE it is intentionally ignored to preserve the
canonical ATTE efficient influence function used by the estimator.
Initialization
Initialize the estimator and validate configuration options.
Canonical target
causalis.scenarios.unconfoundedness.model.IRM
Sections