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
Wtakes 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 withY_{t-1} = 1returns toY_t = 0with probability at least 0.15. The history reaches two nodes back.L_t,A_t,C_tandY_teach readY_{t-1}.A_t,C_tandY_talso readY_{t-2}, andL_tandY_treadL_{t-1}. The second-order terms act att = 3only, becauseY_0,Y_{-1},L_0andL_1are zero. Censoring readsL_t,Y_{t-1},Y_{t-2}andA_tand neverY_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,Y3in time order.C_t = 0setsY_tand every later node tonan. Declare the outcome withoutcome=Repeated(["Y1", "Y2", "Y3"])and the covariates withtime_varying=[[], ["L2"], ["L3"]].truthholdsey_regimen[... @ t=h]fornever,alwaysandREPEATED_RULE_LABELath = 1, 2, 3, andate_regimen[... vs never @ t=h]for the other two plans, under the names a fit reports them by.- 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.
- backend{“pandas”, “polars”, “pyarrow”}
orNone, default=None Dataframe backend.
Noneuses pandas when installed, then the first available backend.
- n
- Returns: