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: L2 is caused by A1 and causes both A2 and the hazard at the second node. Returns (frame, truth).

The frame is wide, with columns W1, W2, A1, C1, Y1, L2, A2, C2, Y2 in time order. A unit that is censored or that has the event has nan at every node after, which is what an absorbing outcome means and what LongitudinalData requires – so the missingness here has two causes rather than one, and a fit that conflated them would answer for a different population.

truth holds risk_regimen[... @ t=k] for the four static regimens at both horizons, and the contrast of always against never at 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 treatment longitudinal_rule_truth() gives it, twice over, and a rule under a survival outcome is already checked exactly in tests/discrete_law_survival.py.

Parameters:
nint

Number of units.

seedint, Generator, or None

Seed or NumPy random generator.

censoringbool

Whether to generate monotone censoring. False leaves every unit observed.

cluster_sizeint or None

Rows per cluster. None leaves the rows independent.

backend{“pandas”, “polars”, “pyarrow”} or None, default=None

Dataframe backend. None uses pandas when installed, then the first available backend.

Returns:
dataframe

Wide-format observations with one absorbing event node per time point.

truthdict of str to float

Cumulative incidence by regimen and horizon, under a fit’s own labels.