cleverly.datasets.make_clustered#
- cleverly.datasets.make_clustered(n: int = 1000, *, seed: int | Generator | None = None, cluster_size: int = 10, backend: Literal['pandas', 'polars'] | str | None = None, family: str = 'gaussian') tuple[Any, dict[str, float]][source]#
Clustered data with an unobserved shared effect modifying the treatment effect.
The third latent variable is shared within a cluster and is deliberately not included among the covariates, so the influence curves are correlated within clusters. Ignoring
cluster=here understates the standard error – which is exactly what the cluster-variance test checks.It moves
Yand, being independent ofA, leaves the ATE identified from the covariates that are emitted; seeclustered_dgp()for why both of those are necessary and why an additive shared effect would give neither.family="binomial"gives a 0/1 outcome with the same cluster structure, so the risk ratio and the odds ratio have a clustered law to be checked on.- Parameters:
- n
int Number of observations.
- seed
int,Generator,orNone Seed or NumPy random generator.
- cluster_size
int Number of rows per cluster.
- backend{“pandas”, “polars”, “pyarrow”}
orNone, default=None Dataframe backend.
Noneuses pandas when installed, then the first available backend.- family{“gaussian”, “binomial”}
Outcome family of the generated outcome.
- n
- Returns: