SimulatedCompetingRisks

Usage

Source

SimulatedCompetingRisks(
    surv,
    covariates,
    latent_times,
    censoring_time,
)

Bundles the simulated survival response, covariate matrix, and latent ground-truth times into a single object. This makes it easy to pass synthetic data directly to competing-risks estimators and metrics.

Attributes

surv: Surv

A multi-state Surv response ready for use with AalenJohansen, FineGray, or any competing-risks metric.

covariates: Array | None

Covariate matrix of shape (n, n_covariates), or None when n_covariates=0.

latent_times: Array

Per-cause latent event times of shape (n, n_causes) before the competing-risks minimum is taken. Useful for constructing oracle predictions in tests and benchmarks.

censoring_time: Array
The censoring time for each subject, shape (n,). The observed time is min(min(latent_times, axis=1), censoring_time).

Examples

Generate synthetic competing-risks data with two causes and three covariates. The result holds a ready-to-use Surv response and covariate matrix:

import greenwood as gw

sim = gw.simulate_competing_risks(
    n=500, n_causes=2, n_covariates=3, seed=42
)
sim.surv
Surv(type=mright, n=500, events=296, states=('cause1', 'cause2'))

The covariates and latent times are available for oracle comparisons:

sim.covariates.shape, sim.latent_times.shape
((500, 3), (500, 2))