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
W2is not merely unnecessary, it is harmful. BecauseW2does not confound, including it ingleaves 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. OmittingW1on 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 takeW1and leaveW2, which is the resultCTMLEis built to deliver. The effect is constant, soate == att == atc == 1.- Parameters:
- n
int Number of observations.
- seed
int,Generator,orNone Seed or NumPy random generator.
- instrument_strength
float Coefficient of
W2in the treatment mechanism, and so how hard the instrument pushes the propensity towards its bounds.- backend{“pandas”, “polars”, “pyarrow”}
orNone, default=None Dataframe backend.
Noneuses pandas when installed, then the first available backend.
- n
- Returns: