cleverly.datasets.make_longitudinal_repeated#

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

Three time points, a repeated binary outcome at each, and monotone censoring.

The baseline covariate W takes the values 0, 1 and 2 with equal probability, and every later node is binary. The outcome is measured at every node and is not absorbing: a unit with Y_{t-1} = 1 returns to Y_t = 0 with probability at least 0.15. The history reaches two nodes back. L_t, A_t, C_t and Y_t each read Y_{t-1}. A_t, C_t and Y_t also read Y_{t-2}, and L_t and Y_t read L_{t-1}. The second-order terms act at t = 3 only, because Y_0, Y_{-1}, L_0 and L_1 are zero. Censoring reads L_t, Y_{t-1}, Y_{t-2} and A_t and never Y_t, so it is missing at random given the history. repeated_truth() enumerates each truth exactly. Returns (frame, truth).

The frame is wide, with columns W, A1, C1, Y1, L2, A2, C2, Y2, L3, A3, C3, Y3 in time order. C_t = 0 sets Y_t and every later node to nan. Declare the outcome with outcome=Repeated(["Y1", "Y2", "Y3"]) and the covariates with time_varying=[[], ["L2"], ["L3"]].

truth holds ey_regimen[... @ t=h] for never, always and REPEATED_RULE_LABEL at h = 1, 2, 3, and ate_regimen[... vs never @ t=h] for the other two plans, under the names a fit reports them by.

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 one outcome node per time point.

truthdict of str to float

Outcome means by plan and horizon, and contrasts against never, under a fit’s own labels.