# `causalis.scenarios.iv.model`

Instrumental Interactive Regression Model for binary IV LATE estimation.

## Module Contents

### Classes

`IIVM` | DoubleML-style IIVM estimator for LATE with binary treatment and IV.

### Data

`__all__` |

### API

class causalis.scenarios.iv.model.IIVM(data: Optional[causalis.data_contracts.iv_causal_data.IVCausalData] = None, ml_g: Any = None, ml_m: Any = None, ml_r: Any = None, *, n_folds: int = 5, n_rep: int = 1, normalize_ipw: bool = False, trimming_rule: str = 'truncate', trimming_threshold: float = 0.01, weak_iv_threshold: float = 0.01, random_state: Optional[int] = None, n_jobs: int = 1)

  Bases: `sklearn.base.BaseEstimator`

  DoubleML-style IIVM estimator for LATE with binary treatment and IV.

  The model consumes :class:`~causalis.data_contracts.IVCausalData`, which stores exactly one binary instrument. It cross-fits nuisance functions:

  .. math::

      g_0(z, X) = \mathbb{E}[Y \mid Z=z, X],
      \quad
      r_0(z, X) = \mathbb{E}[D \mid Z=z, X],
      \quad
      m_0(X) = \mathbb{P}(Z=1 \mid X).

  `estimate(score="LATE")` then solves the linear orthogonal score

  .. math::

      \psi(W; \theta, \eta) = \phi_Y(W; \eta) - \theta \phi_D(W; \eta),

  returning

  .. math::

      \hat\theta = \mathbb{E}_n[\phi_Y] / \mathbb{E}_n[\phi_D].

  where the orthogonal signals are:

  .. math::

      \phi_Y(W; \eta) &= g(1, X) - g(0, X) + \frac{Z(Y - g(1, X))}{m(X)} - \frac{(1-Z)(Y - g(0, X))}{1 - m(X)} \\
      \phi_D(W; \eta) &= r(1, X) - r(0, X) + \frac{Z(D - r(1, X))}{m(X)} - \frac{(1-Z)(D - r(0, X))}{1 - m(X)}

  Notes

  The Local Average Treatment Effect (LATE) is the effect of the treatment among “compliers” — those whose treatment status is changed by the instrument.

  Examples

  > > > from causalis.scenarios.iv.dgp import generate_offer_iv_26 from causalis.data_contracts.iv_causal_data import IVCausalData from causalis.scenarios.iv.model import IIVM data = generate_offer_iv_26(n=5000, return_causal_data=False) causal_data = IVCausalData.from_df( … df=data, … treatment=’accepted_offer’, … outcome=’net_revenue_90d’, … instruments=’offer_eligible’, … confounders=[‘age’, ‘tenure_months’, ‘annual_income’] … ) model = IIVM() model.fit(causal_data) result = model.estimate(score=”LATE”) result.summary()

  Initialization

  fit(data: Optional[causalis.data_contracts.iv_causal_data.IVCausalData] = None) → causalis.scenarios.iv.model.IIVM

    Fit cross-fitted nuisance functions for IIVM.

  estimate(score: str = 'LATE', alpha: float = 0.05) → causalis.data_contracts.iv_causal_estimate.IVCausalEstimate

    Estimate LATE from cross-fitted IIVM nuisance predictions.

  property diagnostics_: Dict[str, Any]

    Return fit-time diagnostic arrays.

  property coef: numpy.ndarray

    Return the estimated coefficient.

  property se: numpy.ndarray

    Return the standard error.

  property pvalues: numpy.ndarray

    Return p-values.

  property summary: pandas.DataFrame

    Return the latest estimate summary table.

  confint() → pandas.DataFrame

    Return the latest confidence interval as a DataFrame.

  __repr__() → str

    Concise representation of IIVM to avoid verbose learner output.

causalis.scenarios.iv.model.__all__

  [‘IIVM’, ‘IVCausalEstimate’]