cleverly.datasets.make_linear_ate#

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

Generate point-treatment data with a constant additive effect.

Parameters:
nint

Number of observations.

seedint, random.Generator, or None

Seed or NumPy random generator.

effectfloat

Additive treatment effect used by the data-generating process.

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 outcome, treatment, and adjustment columns.

truth

Exact causal parameters for the data-generating process.

See also

cleverly.datasets.make_nonlinear_ate

The same estimand, with nuisances a GLM misses.

cleverly.datasets.make_weak_overlap

The same estimand, under a positivity strain.

cleverly.PointTreatment

The design declaration for the columns above.

Notes

A correctly specified generalized linear model can represent both nuisance functions in this data-generating process. Because the effect is constant, ate, att, atc, and effect have the same value.

This generator provides a basic estimator check. It is not statistical evidence for repeated-sampling performance.

Examples

>>> from cleverly.datasets import make_linear_ate
>>> frame, truth = make_linear_ate(n=40, seed=1)
>>> list(frame.columns)
['Y', 'A', 'W1', 'W2', 'W3', 'W4']
>>> truth["ate"]
1.5

effect sets the constant additive effect, so the truth follows it:

>>> data, truth = make_linear_ate(n=20, seed=1, effect=2.0)
>>> data.shape
(20, 6)
>>> truth["ate"]
2.0

truth also holds each draw’s realised sample estimand under a sample_ prefix, which is what a coverage study compares against when it asks about the sample rather than the population parameter:

>>> sorted(key for key in truth if key.startswith("sample_"))
['sample_atc', 'sample_ate', 'sample_att', 'sample_ey0', 'sample_ey1']