cleverly.datasets.make_cde#

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

Controlled direct effect: the effect of A with Z held fixed.

The truth reported is the CDE at intermediate_value. With the interaction in this process the CDE differs between z = 0 (0.9) and z = 1 (1.5), so a fit that ignores Z cannot match either.

Parameters:
nint

Number of observations.

seedint, Generator, or None

Seed or NumPy random generator.

intermediate_valuefloat

Level the intermediate variable is held at when the truth is computed.

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 intermediate column Z.

truthdict of str to float

Exact causal parameters for the data-generating process.