cleverly.datasets.make_longitudinal_survival#
- cleverly.datasets.make_longitudinal_survival(n: int = 2000, *, seed: int | Generator | None = None, censoring: bool = True, cluster_size: int | None = None, backend: Literal['pandas', 'polars'] | str | None = None) tuple[Any, dict[str, float]][source]#
Two time points, an absorbing event at each, and monotone censoring.
The survival counterpart of
make_longitudinal(), with the same time-varying confounding in it:L2is caused byA1and causes bothA2and the hazard at the second node. Returns(frame, truth).The frame is wide, with columns
W1,W2,A1,C1,Y1,L2,A2,C2,Y2in time order. A unit that is censored or that has the event hasnanat every node after, which is what an absorbing outcome means and whatLongitudinalDatarequires – so the missingness here has two causes rather than one, and a fit that conflated them would answer for a different population.truthholdsrisk_regimen[... @ t=k]for the four static regimens at both horizons, and the contrast ofalwaysagainstneverat each – under the names a fit reports them by, so a coverage study can look each up by the name it read off the result. Static plans only: a rule’s truth needs the two-panel treatmentlongitudinal_rule_truth()gives it, twice over, and a rule under a survival outcome is already checked exactly intests/discrete_law_survival.py.- Parameters:
- n
int Number of units.
- seed
int,Generator,orNone Seed or NumPy random generator.
- censoringbool
Whether to generate monotone censoring. False leaves every unit observed.
- cluster_size
intorNone Rows per cluster.
Noneleaves the rows independent.- backend{“pandas”, “polars”, “pyarrow”}
orNone, default=None Dataframe backend.
Noneuses pandas when installed, then the first available backend.
- n
- Returns: