cleverly.datasets.make_nonlinear_bounded#
- cleverly.datasets.make_nonlinear_bounded(n: int = 1000, *, seed: int | Generator | None = None, backend: Literal['pandas', 'polars'] | str | None = None) tuple[Any, dict[str, float]][source]#
Generate a bounded outcome with nonlinear nuisance functions.
- Parameters:
- Returns:
See also
cleverly.datasets.make_nonlinear_ateThe unbounded outcome with the same propensity.
Notes
The outcome
Yis a proportion. Its known support is the open interval(0, 1). The prespecified outcome bounds for this law are thereforeq_bounds=(0, 1). They come from the law, not from the observed outcomes.The conditional mean of
Yis the expit of a nonlinear predictor, andnonlinear_bounded_dgp()gives its terms. A linear model is misspecified for the propensity and for the outcome mean. The effect varies withW1andW2, soate,att, andatcdiffer.The propensity is
0.05 + 0.90 expit(u(W)), so it lies in[0.05, 0.95]. This strong positivity keeps the ATE efficiency bound finite.nonlinear_dgp()givesuand the reason.The truth holds
ey1,ey0,ate,att, andatc. It holds norroror, because a fit treats a proportion as a continuous outcome and refuses those estimands for it.Examples
>>> from cleverly.datasets import make_nonlinear_bounded >>> frame, truth = make_nonlinear_bounded(n=200, seed=1) >>> list(frame.columns) ['Y', 'A', 'W1', 'W2', 'W3', 'W4'] >>> bool(frame["Y"].between(0.0, 1.0, inclusive="neither").all()) True >>> sorted(key for key in truth if not key.startswith("sample_")) ['atc', 'ate', 'att', 'ey0', 'ey1']