survivalgpu.simulate_dataset
- survivalgpu.simulate_dataset(max_time, n_patients, list_covariates, compress=False, seed=None)
Simulates a long-format survival dataset with covariates matched to target hazard ratios.
For each covariate in list_covariates, generates a trajectory for n_patients simulated patients over max_time time points (WCE covariates additionally generate their cumulative-exposure WCEvector). Independently, simulates event/censoring times for n_patients output patients (event_censor_generation / event_FUP_Ti_generation, with a 50% censoring ratio). matching_algo then assigns each output patient one of the simulated covariate trajectories, drawn with a probability that depends on the covariate’s value at the patient’s event time and on HR_target (for WCE covariates) or exp(coef) (for Cox covariates), so that the resulting dataset reproduces the target hazard ratios. Finally, get_dataset assembles the long-format dataset from the matched trajectories.
- Parameters:
max_time (int) – the maximum follow-up time.
n_patients (int) – the number of patients to simulate.
list_covariates (list[WCECovariate | TimeDependentCovariate | ConstantCovariate]) – the covariates to simulate. Each must be an instance of exactly one of these three classes.
compress (bool, optional) – if True, collapse consecutive intervals with identical covariate values via compress_dataset. Defaults to False.
seed (int, optional) – random seed, for reproducibility. Defaults to None.
- Returns:
pandas.DataFrame –
- long-format dataset with columns “patients”, “fup”,
”start”, “stop”, “events”, plus one column per covariate (named after covariate.name).