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:
- n
int Number of observations.
- seed
int,random.Generator,orNone Seed or NumPy random generator.
- effect
float Additive treatment effect used by the data-generating process.
- backend{“pandas”, “polars”, “pyarrow”}
orNone, default=None Dataframe backend.
Noneuses pandas when installed, then the first available backend.
- n
- Returns:
dataframeSimulated observations with outcome, treatment, and adjustment columns.
truthExact causal parameters for the data-generating process.
See also
cleverly.datasets.make_nonlinear_ateThe same estimand, with nuisances a GLM misses.
cleverly.datasets.make_weak_overlapThe same estimand, under a positivity strain.
cleverly.PointTreatmentThe 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, andeffecthave 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
effectsets 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
truthalso holds each draw’s realised sample estimand under asample_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']