cleverly.datasets.make_binary_outcome#

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

A binary outcome with known risks, risk ratio and odds ratio.

Note that the marginal risk ratio reported in truth is the marginal one – a ratio of standardised risks – not the conditional odds ratio in the structural logistic model. They differ, and conflating them is a common source of apparent “bias” that is really a different estimand.

Parameters:
nint

Number of observations.

seedint, Generator, or None

Seed or NumPy random generator.

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 binary outcome, treatment, and covariates.

truthdict of str to float

Exact causal parameters for the data-generating process.