cleverly.datasets.make_longitudinal_competing#

cleverly.datasets.make_longitudinal_competing(n: int = 2000, *, seed: int | Generator | None = None, censoring: bool = True, backend: Literal['pandas', 'polars'] | str | None = None) → tuple[Any, dict[str, float]][source]#

Two time points, two competing absorbing causes at each, monotone censoring.

The competing-risks counterpart of make_longitudinal_survival(), sharing its hazards and its time-varying confounding: an event happens with the same all-cause probability, and a second draw decides which cause it was. Returns (frame, truth).

The frame is wide, with columns W1, W2, A1, C1, R1, D1, L2, A2, C2, R2, D2 in time order – one indicator per cause per node, which is the declaration LongitudinalData takes. A unit that is censored or that has either event has nan at every node after.

truth holds cif_regimen[..., cause @ t=k] for the four static regimens at both causes and both horizons, and the contrast of always against never at each, under the names a fit reports them by – so a coverage study looks each up by the name it read off the result.

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.

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 two competing event nodes per time point.

truthdict of str to float

Cause-specific cumulative incidence by regimen, cause, and horizon.