cleverly.datasets.make_instrument#

cleverly.datasets.make_instrument(n: int = 1000, *, seed: int | Generator | None = None, instrument_strength: float = 1.5, backend: Literal['pandas', 'polars'] | str | None = None) → tuple[Any, dict[str, float]][source]#

Instrument-inflation: a covariate that predicts treatment but not the outcome.

Adjusting for W2 is not merely unnecessary, it is harmful. Because W2 does not confound, including it in g leaves the bias where it was while pushing propensity scores towards 0 and 1, which inflates the variance of the clever covariate and hence of the estimate. Omitting W1 on the other hand is biasing. A propensity model chosen by prediction accuracy takes both; one chosen collaboratively – against the loss of the targeted outcome model – should take W1 and leave W2, which is the result CTMLE is built to deliver. The effect is constant, so ate == att == atc == 1.

Parameters:
nint

Number of observations.

seedint, Generator, or None

Seed or NumPy random generator.

instrument_strengthfloat

Coefficient of W2 in the treatment mechanism, and so how hard the instrument pushes the propensity towards its bounds.

backend{“pandas”, “polars”, “pyarrow”} or None, default=None

Dataframe backend. None uses pandas when installed, then the first available backend.

Returns:
dataframe

Simulated observations with a confounder, an instrument, and a predictor.

truthdict of str to float

Exact causal parameters for the data-generating process.