causalis.scenarios.iv.dgp

High-level instrumental-variable DGPs with realistic business covariates.

Module Contents

Functions

generate_offer_iv_26

Generate a realistic IV dataset with a positive business effect.

Data

__all__

API

causalis.scenarios.iv.dgp.generate_offer_iv_26(n: int = 20000, seed: int = 42, include_oracle: bool = True, return_causal_data: bool = True, *, deterministic_ids: bool = True) Union[pandas.DataFrame, causalis.data_contracts.iv_causal_data.IVCausalData]

Generate a realistic IV dataset with a positive business effect.

This scenario mimics an offer-eligibility experiment in a customer product:

  • offer_eligible is the binary instrument (Z). It affects whether customers can accept an offer, but it has no direct outcome effect in the DGP.

  • accepted_offer is the binary endogenous treatment (D).

  • net_revenue_90d is a continuous outcome (Y) with a positive heterogeneous treatment effect among customers induced into treatment by eligibility.

The DGP follows a structural model where unobserved confounders :math:U affect both treatment :math:D and outcome :math:Y, but not the instrument :math:Z:

.. math::

Z &= f_Z(X, \epsilon_Z) \
D &= f_D(Z, X, U, \epsilon_D) \
Y &= f_Y(D, X, U, \epsilon_Y)

Parameters

n : int, default 20_000 Number of observations to generate. seed : int, default 42 Random seed for reproducibility. include_oracle : bool, default True Whether to include latent variables (ITE, LATE, etc.) in the output DataFrame. return_causal_data : bool, default True If True, returns an :class:~causalis.data_contracts.iv_causal_data.IVCausalData object. If False, returns a :class:pandas.DataFrame. deterministic_ids : bool, default True Whether to generate stable, deterministic user IDs.

Returns

Union[pd.DataFrame, IVCausalData] The generated dataset.

Examples

from causalis.scenarios.iv.dgp import generate_offer_iv_26

Generate data as a pandas DataFrame

data = generate_offer_iv_26(n=5000, return_causal_data=False) data[[‘offer_eligible’, ‘accepted_offer’, ‘net_revenue_90d’]].head()

causalis.scenarios.iv.dgp.__all__

[‘generate_offer_iv_26’]