Manuscript Offprint
arXiv:2610.38475survivalGPU: Scalable Survival Analysis for R and Python
Antoine Poirot-Bourdain
CNRS, INRIA, INSERM Université Paris-Dauphine PSL Université Paris Cité
Alexis Van Straaten
AP-HP, INRIA, INSERM Université Paris Cité
Emmanuel Bacry
CNRS Université Paris-Dauphine PSL
Anne-Sophie Jannot
AP-HP, INRIA, INSERM Université Paris Cité
Jean Feydy
INRIA, INSERM Université Paris Cité
Abstract
This paper introduces survivalGPU, a high-performance Python and R package designed to accelerate survival analysis computations using graphics processing units (GPUs). While the Cox proportional hazards model remains a cornerstone of survival analysis, it can impose substantial computational burdens when applied to large longitudinal data sets. To address this limitation, survivalGPU implements Cox proportional hazards models and weighted cumulative exposure (WCE) models in Python, using PyTorch and KeOps for efficient back-end computation, with interfaces in both Python and R. Numerical validation shows that survivalGPU reproduces the results of reference implementations within the tolerances expected for the selected floating-point precision, with relative errors below in float32 and below in float64. Benchmark experiments demonstrate substantial speedups. For Cox models, coxphGPU() was faster than coxph() from the survival package on 1,000,000 patients, and faster based on runtimes extrapolated to 1,000 bootstrap replicates on 100,000 patients. Gains were larger for WCE models: wceGPU() was faster than WCE() from the WCE package on 100,000 patients, and faster based on runtimes extrapolated to 1,000 bootstrap replicates. These results show that survivalGPU makes flexible time-dependent survival modeling and bootstrap-based estimation of confidence intervals feasible for large-scale pharmacoepidemiological applications.
Keywords: R, Python, survival analysis, WCE, Cox model, GPU computing, bootstraps.
1. Introduction
Scalable survival analysis. Survival analysis is used to analyze time-to-event data. The Cox proportional hazards model (Cox 1972) is one of the most widely used models for survival analysis and can be extended to handle time-dependent covariates. The weighted cumulative exposure (WCE) model (Sylvestre and Abrahamowicz 2009) extends this framework to time-dependent exposures by summarizing past exposures through a time-lagged weight function that captures the cumulative impact of historical exposure. This approach is particularly useful in longitudinal pharmacoepidemiological research (Pazzagli, Linder, Zhang, Vago, Stang, Myers, Andersen, and Bahmanyar 2018; Sapir-Pichhadze, Laprise, Beauchamp, Kaouache, Zhang, Della Vecchia, Azoulay, Franco, Abrahamowicz, and Nicolau 2024; Dayan, Beauchamp, Kountourides, Pilote, and Abrahamowicz 2026).
Despite their widespread utility, traditional implementations of the Cox model and its extensions face substantial barriers when applied to modern, large-scale databases. These computational bottlenecks arise from two primary sources:
-
Algorithmic complexity. Methods incorporating time-dependent covariates typically rely on a counting-process representation, in which each individual contributes one or more rows corresponding to intervals where covariate values remain unchanged. If denotes the total number of such rows, repeated risk-set evaluations may scale as in standard implementations (Yang, Schuemie, Ji, and Suchard 2024). Consequently, cohorts with hundreds of thousands of individuals can yield even larger numbers of follow-up intervals, making serial CPU implementations prohibitively time-consuming.
-
Iterative computational demands. To address high-dimensional covariate spaces, tune model specifications, and quantify uncertainty, practitioners increasingly rely on regularization, cross-validation, and resampling-based procedures such as bootstrapping (Efron 1979). Interpretation techniques such as Shapley values (Sundararajan and Najmi 2020) can also require many repeated model evaluations. These procedures multiply the computational burden by several orders of magnitude.
Existing packages. Survival analysis software in R and Python has traditionally relied on CPU-based execution. In R, the survival package (Therneau 2024) serves as the de facto standard, providing the foundation for domain-specific extensions such as the WCE package (Sylvestre, Beauchamp, Kyle, and Abrahamowicz 2024), which implements the weighted cumulative exposure model. The Python ecosystem offers robust alternatives, including scikit-survival (Pölsterl 2020), lifelines (Davidson-Pilon 2019), statsmodels (Seabold and Perktold 2010), and tick (Bacry, Bompaire, Gaïffas, and Poulsen 2018). While some of these libraries are highly optimized, they are primarily CPU-oriented and do not directly target GPU-accelerated fitting of Cox and WCE models.
Recent efforts to leverage massively parallel graphics processing units (GPUs) for survival analysis have followed two distinct architectural trajectories:
- Low-level CUDA/C++ implementations. Optimized implementations such as CUDA_Cox (Andalibi, Christophe, Laukkarinen, and Mikkonen 2016), xgboost (Barnwal, Cho, and Hocking 2022), and Cyclops (Yang et al. 2024) use compiled backends or specialized optimization routines to improve scalability. While these tools can achieve
high performance, their rigid architecture may make it difficult for researchers to modify the underlying objective functions or incorporate custom penalties.
- Deep learning frameworks. Libraries such as pycox (Kvamme 2024) and TorchSurv (Monod, Krusche, Cao, Sahiner, Petrick, Ohlssen, and Coroller 2024) use the high-level PyTorch framework (Paszke, Gross, Chintala, Chanan, Yang, DeVito, Lin, Desmaison, Antiga, and Lerer 2017). They trade some degree of low-level optimization for the flexibility of automatic differentiation and seamless integration into modern machine learning pipelines.
In this context, there remains a need for a solution that bridges these two worlds: a package that provides the computational efficiency of an optimized GPU backend while maintaining the familiar syntax and statistical rigor of reference packages such as R's survival.
Contributions. To address this challenge, we introduce survivalGPU, a high-performance package for large-scale survival analysis with the following key features:
-
Model support. We implement Cox and WCE models with native support for bootstrap estimation.
-
Accessible interfaces. We provide user-friendly interfaces for both R and Python.
-
Modular and efficient GPU backend. We use PyTorch for automatic differentiation and tensor-based optimization, and KeOps (Charlier, Feydy, Glaunès, Collin, and Durif 2021) for memory-efficient estimation of the WCE-derived time-dependent covariates. This architecture provides substantial computational gains while remaining extensible through pure Python.
-
Reliability. We show numerical agreement with reference implementations within precision-specific relative tolerances in both float32 and float64.
-
Performance. Benchmark experiments demonstrate substantial speedups. For Cox models, at , coxphGPU() required 2.75 seconds on the GPU, compared with 15.35 seconds for coxph() from the survival package, corresponding to a speedup. With bootstrap replicates on patients, coxphGPU() required 71.64 seconds (1.19 minutes), compared with 1,004.62 seconds (16.74 minutes) for the extrapolated survival runtime, corresponding to a speedup. Gains were larger for WCE models: at , wceGPU() required 9.83 seconds, compared with 9,050.72 seconds (2.51 hours) for WCE() from the WCE package, corresponding to a speedup. With bootstrap replicates, wceGPU() required 5,021.78 seconds (1.39 hours), compared with an extrapolated runtime of 6,635,933.69 seconds (76.80 days) for WCE(), corresponding to a speedup.
Our work is motivated by the emergence of nation-scale medico-administrative databases, such as the Système National des Données de Santé (SNDS) in France, which have transformed clinical research by enabling longitudinal studies on millions of patients (Maillard, Bun, Laanani, Verga-Gérard, Leroy, Gault, Estellat, Noize, Kaguelidou, Sommet, Lapeyre-Mestre, Fourrier-Réglat, Weill, Quantin, and Tubach 2024; Cairat, Severi, Huybrechts, and Fournier 2025; Wyplosz, Fernandes, Sultan, Roche, Roubille, Loubet, Fougère, Moulin, Duhot, Vainchtock,
Raguideau, Lortet-Tieulent, Blanc, Moïsi, and Goussiaume 2022; Soeiro, Uras, Jouanjus, Lapeyre-Mestre, and Micallef 2025).
The remainder of the paper is organized as follows. Section 2 introduces the survival analysis framework, with a focus on the Cox proportional hazards model and its WCE extension. Section 3 describes the implementation of survivalGPU, including the use of torch and KeOps for accelerated computation. Section 4 presents the Python and R interfaces. Section 5 reports the implementation validation in both float32 and float64, and Section 6 presents the benchmark study against existing reference implementations using float32. Section 7 provides an empirical illustration of the package. Finally, Section 8 concludes with a discussion of current limitations and future developments.
2.1. Time-to-event data
Survival analysis models time-to-event data. An event is an outcome of interest, such as the death of a patient or the diagnosis of a disease (Clark, Bradburn, Love, and Altman 2003). Event times may be censored, meaning that the exact event time is not fully observed within an individual-specific observation window. With right censoring, the event time is known only to exceed the censoring time. With left censoring, the event time is known only to precede the censoring time.
Notation. We define as a random variable representing a survival or event time. We denote by the survival function, which represents the probability that an individual remains event-free past time :
The hazard function is the instantaneous rate of occurrence of events among individuals who are still at risk at time :
2.2. The Cox model
The Cox proportional hazards model (Cox 1972) is one of the most widely used models in survival analysis. For a model with covariates, possibly time-dependent but with time-fixed coefficients, the hazard function for individual at time is
where is the unspecified baseline hazard, is the vector of covariate values for individual , and is the vector of regression coefficients.
The model is semi-parametric: the effect of the covariates is modeled through the exponential of the linear predictor , while the shape of the baseline hazard function is left unspecified.
Antoine Poirot-Bourdain, Alexis Van Straaten, Emmanuel Bacry, Anne-Sophie Jannot, Jean Feydly
The proportional hazards assumption implies that, for two individuals with covariate vectors and , the hazard ratio is
For time-independent covariates, this ratio is constant over time. In particular, a one-unit increase in covariate , all other covariates being equal, multiplies the hazard by .
The regression coefficients are estimated by maximizing the Cox partial likelihood. Let , , denote the ordered event times, and let denote the individual experiencing the event at time . Assuming distinct event times, the partial likelihood is
where is the number of observed events and is the risk set at time , defined as the set of individuals still under observation just before . Tied event times require specific approximations, such as the Breslow or Efron methods. Standard likelihood-based optimization and inference procedures can then be applied to the partial likelihood to estimate the coefficient vector .
2.3. The WCE model
The weighted cumulative exposure (WCE) model (Sylvestre and Abrahamowicz 2009) extends the Cox model by replacing the current exposure value with a weighted summary of past exposures. Consider a cohort of patients in which exposure intensity varies over time. At any follow-up time u, the exposure history is summarized by the WCE metric
where indexes previous exposure times, is the exposure at time , and is the weight assigned according to the time elapsed since exposure. The WCE metric is then used as a time-dependent covariate in the Cox model:
where is the exposure history up to time , is the vector of additional Cox covariates, and is the vector of their coefficients. In practice, is set to zero for lags , where is the cutoff defining the maximum lag over which past exposures are assumed to influence the current hazard.
The weight function is modeled using a linear combination of cubic B-splines:
(8) where , , are the spline basis functions and are their coefficients. Substituting equation (8) into equation (7) gives
Conceptually, describes the shape of the weight function and the magnitude of the cumulative exposure effect. However, both and the spline coefficients determine the strength of the association between exposure and risk, which creates an identifiability problem. Following Sylvestre and Abrahamowicz (2009), we define
Estimation is then simplified by defining artificial time-dependent covariates, called WCE-derived covariates,
The hazard function can therefore be written in the familiar Cox model form:
where is the vector of WCE-derived covariates, and is the vector of their estimable coefficients.
Estimation. Once the spline basis has been specified, the WCE-derived covariates can be computed for each follow-up time. The Cox partial likelihood in equation (5) can then be maximized to estimate and .
Hazard ratios. Because is absorbed into , the fitted model does not separately estimate a scalar exposure coefficient and a normalized weight function. Instead, hazard ratios are obtained by comparing exposure histories. For two hypothetical exposure histories and , evaluated at time with identical values of the adjustment covariates, the estimated hazard ratio is
Confidence intervals for such contrasts can be obtained using patient-level bootstrap resampling (Efron 1979).
Hyperparameters. The previous equations assume that the spline basis has already been fixed. In practice, this basis depends on hyperparameters that control the flexibility and support of the estimated weight function.
- nknots: the number of interior knots used in the cubic B-spline representation of the weight function. A cubic B-spline basis with basis functions corresponds to
interior knots. Increasing the number of knots increases the flexibility of the estimated weight function, but also increases the risk of overfitting. In practice, following Sylvestre and Abrahamowicz (2009), a small number of interior knots, typically between 1 and 3, is usually sufficient.
-
cutoff: the maximum lag over which past exposures are assumed to influence the current hazard. The weight function is estimated on the interval , and exposures occurring before are assigned a weight of zero. The cutoff therefore defines the time window of etiologically relevant exposure. It also determines the scale over which the spline knots are distributed: a large cutoff spreads the knots over a wider interval, whereas a small cutoff concentrates them on more recent exposure times.
-
constrained: whether a boundary constraint is imposed at the right end of the exposure window. In the right-constrained specification, the last two spline coefficients are fixed to zero so that the estimated weight function reaches zero smoothly at the cutoff. This constraint is useful when it is assumed that exposures older than the cutoff should have no residual effect on the hazard.
Model selection. In practice, the model is fitted over a grid of hyperparameter values. In the analyses reported below, we consider 1 to 3 interior knots and both constrained and unconstrained specifications. Model selection is performed using the Bayesian information criterion (BIC) (Schwarz 1978):
where denotes the partial likelihood, is the number of estimated regression parameters, including the WCE-derived covariate coefficients and any adjustment covariate coefficients, and is the number of observed events. The selected model is the specification with the lowest BIC.
The comparison between constrained and unconstrained specifications is informative for the choice of cutoff. If an unconstrained model assigns substantial weight near the right boundary, this may indicate that the cutoff is too short to capture the full exposure-risk relationship. Conversely, if the right-constrained model is selected, this is consistent with the assumption that the exposure effect vanishes by the end of the chosen time window.
3. GPU-powered survival analysis
3.1. Architecture of the survivalGPU package
Package architecture. The survivalGPU package provides a GPU-accelerated implementation of Cox and WCE models. It is composed of a computational backend implemented in Python and an R interface that allows users to call the main functions within an R environment. Users can fit Cox and WCE models from either language, while the core computations are performed in Python, including GPU-specific routines.
Floating-point precision. The computational backend supports both single- and double-precision floating-point arithmetic, through float32 and float64 tensors, respectively. The choice of precision is important for GPU-based statistical software, because single precision requires less memory and is often substantially faster, whereas double precision may be preferred when numerical accuracy is the main concern. Similar trade-offs between single- and double-precision arithmetic have been discussed in previous GPU-oriented statistical software papers (Casarin, Grassi, Ravazzolo, and van Dijk 2015). In survivalGPU, float32 is therefore the recommended setting for GPU acceleration, especially on hardware with limited double-precision throughput, while float64 remains available for sensitivity analyses. This precision option applies to both main computational steps described below: the construction of the WCE-derived covariates in Section 2.3 and the maximization of the Cox partial likelihood in Section 2.2. In Section 5, we compare the precision modes to assess numerical agreement with the reference implementations. In contrast, the computational benchmarks in Section 6 are reported using float32, corresponding to the recommended high-performance configuration.
Computational bottlenecks. From a computational standpoint, the main bottlenecks depend on the model being fitted. For the WCE model, the most intensive step is the construction of the artificial time-dependent covariates, referred to here as WCE-derived covariates, defined in equation (11). These covariates encode the exposure history of each individual through the spline basis and must be computed before maximizing the Cox partial likelihood.
For both Cox and WCE models, maximizing the Cox partial likelihood in equation (5) also contributes to runtime. In the Cox model, this is the main computational step. In the WCE model, it follows the construction of the WCE-derived covariates and remains an important contributor to runtime.
3.2. Estimation of the WCE-derived covariates
Construction of WCE-derived covariates. As described in Section 2.3, the WCE model transforms the exposure history into artificial time-dependent covariates by convolving it with the cubic B-spline basis functions . For each basis spline , the corresponding WCE-derived covariate at time u is
In practice, terms with are omitted because beyond the cutoff.
This operation must be repeated for each basis spline, each patient, and each follow-up time at which the time-dependent covariates are evaluated. It is therefore both computationally intensive and memory-demanding, especially when the cohort is large or when follow-up histories are long.
For a single individual, equation (15) can be written as a matrix-vector product. Let denote the vector of exposures over follow-up and let be the structured matrix whose entry is
When a finite cutoff is used, entries with are also zero, so the matrix is banded lower triangular.
Then the vector of values of the th WCE-derived covariate can be written as
When several spline basis functions are used, this operation is repeated for , producing, at each follow-up time , the vector of WCE-derived covariates used in equation (12).
Sparse exposure histories. In many pharmacoepidemiological applications, exposure histories are sparse: patients are unexposed for long periods, and only time points with and contribute to the WCE-derived covariates. The implementation therefore stores and processes only nonzero exposure times. This sparse representation reduces both memory use and computation time, especially when drug exposure is intermittent or when follow-up is long.
Symbolic matrix products with KeOps. Standard tensor libraries, such as PyTorch, are optimized for dense, fixed-size tensor operations. By contrast, the construction of WCE-derived covariates involves irregular patient-specific exposure histories and large structured matrices that should not be explicitly materialized in memory. To address this, survivalGPU relies on KeOps (Charlier et al. 2021; Feydy, Glaunès, Charlier, and Bronstein 2020), which supports symbolic matrix computations and lazy evaluation.
With KeOps, the expression defining the entries is represented symbolically and evaluated only when needed. This avoids storing the full matrices , whose size increases quadratically with the number of follow-up times for each individual. The same symbolic formulation can be executed on the CPU, reducing memory allocation compared with explicit matrix construction, or on the GPU, where the computations are additionally parallelized.

Figure 1: Computation of the WCE-derived covariate for one B-spline and two patients. denotes the set of times at which patient receives a nonzero exposure , and denotes the set of follow-up times at which the WCE-derived covariate is evaluated. The matrix entries correspond to the spline weights , and multiplication by the exposure vector yields the WCE-derived covariate values . The use of KeOps avoids explicitly materializing the full matrix and excludes entries that do not contribute to the computation.
Conceptually, the patient-specific matrices form the diagonal blocks of a larger block matrix. Off-diagonal blocks correspond to combinations of exposure and follow-up times from different patients and must not contribute to the WCE-derived covariates. The off-diagonal interactions are masked in the symbolic expression and are not materialized in memory. This block-diagonal structure allows survivalGPU to compute WCE-derived covariates for all patients using a single symbolic matrix product while preserving patient-specific exposure histories.
3.3. Maximization of the Cox partial likelihood
Optimization strategy. After the covariate matrix has been constructed, the Cox and WCE models are fitted by maximizing the Cox partial likelihood in equation (5). The implementation is conceptually inspired by the survival package in R (Therneau 2024). However, whereas survival relies on compiled C routines, survivalGPU implements the optimization in Python, with tensor operations executed on the CPU or GPU depending on the selected device.
Automatic differentiation. In the survival package, optimization relies on compiled C routines with analytically derived derivatives. In survivalGPU, the derivatives required by the optimizer are computed using automatic differentiation in PyTorch. This avoids manually coding model-specific derivatives and makes the implementation easier to extend to alternative Cox or WCE model formulations, such as penalized objectives.
Extensibility. This architecture separates the definition of the objective function from the implementation of derivative calculations. As a result, extensions of the Cox or WCE likelihood can be implemented by modifying the objective function while relying on automatic differentiation for optimization. This design is useful for future extensions such as penalized estimation or additional Cox model structures.
4. Package overview
The survivalGPU package provides a GPU-accelerated implementation of Cox and WCE models. It is implemented in Python using the torch module of PyTorch and the KeOps package, as described in Section 3. The package can be used either directly from Python or through an R interface. The R interface relies on the reticulate package to call the Python backend, while providing a syntax close to standard R survival analysis packages. Internally, the coxphGPU() and wceGPU() functions call the coxph_R() and wce_R() Python functions, which take a pandas.DataFrame and column names as arguments and dispatch to the object-based estimators described below. This allows us to maintain the numerical part of the code in a single place, in Python. This makes the code simpler to develop and maintain, and reduces the risk of divergence between the two implementations, while making the package available in both R and Python.
Both interfaces expose the floating-point precision option described in Section 3. The backend can use either float32 or float64 arithmetic. The examples below use float32, which is the recommended configuration for GPU acceleration and the configuration used in the benchmark experiments reported in Section 6.
Using the WCE model requires the PyKeOps package, which is available on Linux and macOS but not on Windows. Installing PyKeOps is optional: the Cox model can be used without it. On Windows, PyKeOps can be used through the Windows Subsystem for Linux (WSL). GPU acceleration uses CUDA through the torch and PyKeOps packages and requires an NVIDIA GPU. Code examples can be found in Section 7.
4.1. Python package overview
There exist multiple implementations of the Cox model in Python, such as the lifelines and scikit-survival packages. However, there is no single reference implementation. We decided to follow the conventions of the scikit-learn package whenever possible, as it is well known to Python users. Statistical models are implemented as estimator objects: users initialize an estimator with model-specific options and then estimate the model parameters using the fit() method, which stores the results as attributes of the object. Unlike scikit-survival, fit() takes NumPy arrays rather than a DataFrame with column names, because the low-level interface is designed to be called on data that are already loaded on the target device.
Cox model. The Cox proportional hazards model is implemented by the CoxPHSurvivalAnalysis estimator. Its arguments, and those of its fit() method, are listed in Table 2 alongside their equivalents in the R interface and in coxph() from survival, and its features are compared with existing implementations in Table ??. Both the Breslow and Efron approximations for handling tied event times are implemented and can be selected through the ties argument. The number of bootstrap replicates and the batch size used to process them in parallel on the GPU are specified when the estimator is initialized, through the nbootstraps and batchsize arguments. Numerical precision is controlled by the dtype argument, which accepts np.float32 or np.float64. Single precision reduces memory use for floating-point tensors and can improve runtime on GPU devices, whereas double precision may be preferred when numerical precision is the main concern.
The fitted object stores the estimated coefficients, their standard errors, and the model log-likelihood values as attributes (coef_, std_, loglik_, ...). If nbootstraps is positive, the bootstrap replicates of the coefficients are stored in bootstrap_coef_.
WCE model. The WCE model is implemented by the WCESurvivalAnalysis estimator. Its arguments, and those of its fit() method, are listed in Table 1 alongside their equivalents in the R interface and in WCE() from the WCE package, and its features are compared with those of WCE() in Table ??. In addition to the survival outcome and adjustment covariates, the user specifies the exposure variable and the hyperparameters of the spline basis: the number of knots (nknots), the length of the exposure-risk window (cutoff), and the boundary constraint (constrained, one of "left", "right", or None). When several candidate values are given for nknots, one model is fitted for each candidate and the model that minimizes the information criterion selected by the criterion argument ("aic" or "bic") is retained. As in the reference WCE package, tied event times are handled using the Efron approximation, which is the default in the underlying Cox model. As for CoxPHSurvivalAnalysis, the number of bootstrap replicates and the batch size are specified at initialization through nbootstraps and batchsize, and the dtype argument selects between single- and double-precision arithmetic.
The fitted object exposes the estimated risk function of the selected model as risk_function_, the coefficients of the adjustment covariates as coef_, and the selected number of knots as best_nknots_; the results for all candidates remain available in the *grid attributes. When nbootstraps is positive, all candidates are fitted on the same bootstrap resamples and the number of knots is selected again in each replicate. The bootstrap replicates of the risk function, stored in bootstrap_risk_functions_, therefore account for the uncertainty in the choice of the number of knots, and the number of knots selected in each replicate is stored in bootstrap_best_nknots_. Finally, the HR() method computes the hazard ratio between two exposure profiles from the estimated risk function, together with a bootstrap percentile confidence interval when nbootstraps is positive.
| survivalGPU | WCE | ||
|---|---|---|---|
| Python | R | R | |
| Data | |||
| Data set | Arrays in fit() | data | data |
| Subject identifier | patient | id | id |
| Event indicator | event | event | event |
| Interval bounds | start, stop | start, stop | start, stop |
| Exposure | dose | expos | expos |
| Covariates | covariates (array) | covariates (names) | covariates (names) |
| Strata | strata in fit() | strata() special in formula | strata() special in formula |
| Weight function and model selection | |||
| Number of knots | nknots (integer or list) | nknots (vector) | nknots (vector) |
| Time window | cutoff | cutoff | cutoff |
| Constraint | constrained: None, "left", "right" | constrained: FALSE, "Left", "Right" | constrained: FALSE, "Left", "Right" |
| Information criterion | criterion: "aic", "bic" | aic: TRUE, FALSE | aic: TRUE, FALSE |
| Bootstrap | |||
| Number of replicates | nbootstraps | R in bootstrap() | — |
| Replicates per batch | batchsize | batchsize in bootstrap() | — |
| Confidence level | level in HR() | level in HR() | — |
| Computation | |||
| Precision | dtype (np.float32, np.float64) | double_precision (FALSE, TRUE) | — |
| Device | device | device | — |
Table 1: Inputs of the WCE model in survivalGPU and in WCE() from the WCE package. In Python, options are given to the WCESurvivalAnalysis constructor and data to its fit() method. In R, wceGPU() keeps the argument names of WCE(), and bootstrap options are given to bootstrap() once the model is fitted. In both packages, the data set is in long format, with one row per subject and time unit. Only "Cox" is implemented in WCE.
4.2. R package overview
In R, the package syntax follows the conventions of the survival package and the WCE() function from the WCE package, while adding GPU-specific features such as parallelized bootstrap resampling, batch-wise control of GPU memory use, and explicit control of floating-point precision. The package provides two main functions, coxphGPU() for Cox models and wceGPU() for WCE models, and a bootstrap() generic function. Following the usual practice in R of separating model fitting from inference, a model is first fitted without bootstrap, and bootstrap replicates are added afterwards by calling bootstrap() on the fitted object. The fitted model is not transmitted back to the Python backend: bootstrap() sends the data again, and the backend fits the model once more together with the bootstrap replicates. Because this fit is processed in parallel with the replicates, its additional cost is negligible. In both functions, the double_precision argument selects between double-precision (TRUE, the default, float64) and single-precision (FALSE, float32) arithmetic, and the device argument selects the device on which computations are performed.
| survivalGPU | survival | ||
|---|---|---|---|
| Python | R | R | |
| Data and model | |||
| Survival outcome | start, stop, event in fit() | Surv(start, stop, event) in formula | Surv(start, stop, event) in formula |
| Covariates | covariates (array) in fit() | Right-hand side of formula | Right-hand side of formula |
| Strata | strata in fit() | strata() in formula | strata() in formula |
| Ties | ties | ties | ties |
| Initial values | init in fit() | init | init |
| Maximum iterations | maxiter | iter.max in control | iter.max in control |
| Store the data | – | X (FALSE, TRUE) | X (FALSE, TRUE) |
| Bootstrap | |||
| Number of replicates | nbootstraps | R in bootstrap() | – |
| Patient identifier | patient in fit() | patient_id in bootstrap() | – |
| Replicates per batch | batchsize | batchsize in bootstrap() | – |
| Computation | |||
| Precision | dtype (np.float32, np.float64) | double_precision (FALSE, TRUE) | – |
| Device | device | device | – |
Table 2: Inputs of the Cox model in survivalGPU and in coxph() from survival. In Python, options are given to the CoxPHSurvivalAnalysis constructor and data to its fit() method. In R, coxphGPU() takes the same formula interface as coxph(), and bootstrap options are given to bootstrap() once the model is fitted.
Cox model. The function coxphGPU() fits a Cox proportional hazards model. Its syntax is analogous to coxph() from the survival package (Table 2), and both the Breslow and Efron approximations for tied event times can be selected using the ties argument. Since coxph() is a function rather than an S3 generic, coxphGPU() cannot inherit its handling of the inputs. Instead, coxphGPU() calls survival::coxph() with iter.max = 0, so that no Newton iteration is performed, and retrieves the response, the design matrix and the strata that it builds. Formula parsing, including the strata() special, is thus delegated to the survival package without duplicating its code, and only the preprocessed data are sent to the Python backend. Arguments that the backend does not support, such as weights, offset(), tt(), cluster() and multi-state models, stop with an error.
The function returns an object of class c("coxphGPU", "coxph"), which inherits from the class of coxph() objects. The print(), summary() and coef() methods are redefined for coxphGPU objects, and summary() additionally reports bootstrap percentile confidence intervals when bootstrap replicates are available. Other generic functions, such as predict(), residuals(), update() and cox.zph(), rely on the methods of the survival package, and functions from packages that work with coxph objects, such as ggforest() from survminer, can be applied directly.
Bootstrap confidence intervals are obtained by calling bootstrap(fit, R, patient_id, data, batchsize), where fit is a model fitted with x = TRUE. The patient_id argument identifies the subject associated with each row of data, so that resampling is performed at the
Antoine Poirot-Bourdain, Alexis Van Straaten, Emmanuel Bacry, Anne-Sophie Jannot, Jean Feykhy
patient level rather than at the row level. The batchsize argument controls the number of bootstrap replicates processed in parallel; if memory errors occur, users can reduce batchsize to limit GPU memory use. The function returns a copy of the fitted object to which the bootstrap replicates of the coefficients are added.
WCE model. The function wceGPU() fits a WCE model within the Cox proportional hazards framework. It follows the nomenclature of the WCE() function from the WCE package (Table 1) and uses WCE-specific hyperparameters such as nknots, cutoff and constrained. As in the WCE package, tied event times are handled using the Efron approximation. When several values are given for nknots, one model is fitted for each candidate and, unlike WCE(), which returns all fitted models and leaves the choice to the user, wceGPU() retains the model that minimizes the BIC, or the AIC when aic = TRUE. The selected number of knots is stored in best.nknots, and the information criterion and partial log-likelihood of every candidate are kept in the *.grid fields and displayed by summary(allres = TRUE).
The function returns an object of class "wceGPU". This class does not inherit from the class of WCE() objects: a wceGPU object describes the selected model only, whereas a WCE object contains every fitted model, so the methods of the WCE package would not apply. Instead, wceGPU objects have their own print(), summary(), coef(), confint() and plot() methods, whose output follows that of the WCE package, and an HR() function computes the hazard ratio between two exposure profiles.
Bootstrap confidence intervals are obtained by calling bootstrap(fit, R, data, batchsize). All candidate numbers of knots are fitted on the same resamples, and the number of knots is selected again in each replicate, so that the confidence intervals account for the uncertainty in this choice; the number of knots selected in each replicate is stored in bootstrap.best.nknots. The plot() method then displays the estimated weight function together with its bootstrap confidence band, and HR() reports a bootstrap percentile confidence interval for the hazard ratio.
5. Implementation validation
The objective of the implementation validation was to verify that survivalGPU reproduces results obtained with established reference implementations. This validation focuses on numerical differences between software implementations rather than on the statistical behavior of the estimators. Details on the data generation procedure and simulation scenarios are provided in Appendix A. The benchmark study uses a separate simulation setting described in Section 6.
As described in Section 3, survivalGPU supports both single- and double-precision floating-point arithmetic. The validation was therefore performed in both float32 and float64. This comparison served two objectives. First, it verifies that the implementation reproduces the reference software results when using double precision. Second, it quantifies the numerical differences introduced by the recommended float32 GPU configuration used in the benchmark experiments of Section 6.
Cox model validation. The Cox implementation was validated in two steps. First, we adapted unit tests from the survival package to verify that coxphGPU() reproduces the behavior of coxph() for standard Cox model configurations, including right-censored and counting-process inputs, fixed and time-dependent covariates, tied event times, and the Breslow and
| Scenario | Ties | float32 | float64 | ||
|---|---|---|---|---|---|
| Median MRE | Max MRE | Median MRE | Max MRE | ||
| 1 const. cov. | Efron | ||||
| 1 const. cov. | Breslow | ||||
| 3 const. cov. | Efron | ||||
| 3 const. cov. | Breslow | ||||
| 1 time-dep. cov. | Efron | ||||
| 1 time-dep. cov. | Breslow | ||||
| 3 time-dep. cov. | Efron | ||||
| 3 time-dep. cov. | Breslow | ||||
Table 3: Cox model validation in float32 and float64. Comparison of coxphGPU() from survivalGPU with coxph() from the survival package across simulated data sets of 1,000 patients. Results are reported separately for the Efron and Breslow tied event-time approximations. The scenario labels “const. cov.” and “time-dep. cov.” denote constant covariates and time-dependent covariates, respectively. For each replicate, coefficient-level relative errors were computed using Equation (19) and averaged across covariates to obtain MRE, as defined in Equation (20). The table reports the median and maximum of MRE across simulations for both numerical precisions.
Efron approximations. Second, simulation-based comparisons were used to quantify numerical differences between coxphGPU() and coxph() across repeated simulated data sets.
Four simulation settings were considered: one constant covariate, three constant covariates, one time-dependent covariate, and three time-dependent covariates. Each configuration was replicated times. In each replicate, the hazard ratio associated with each covariate was randomly selected from the set , and the corresponding regression coefficient was defined on the log-hazard-ratio scale as
where denotes the number of covariates in the simulation setting. This sampling scheme includes both protective effects, such as , and increased risks, such as . For each simulated data set, the same model was fitted with coxphGPU() and coxph().
Both the Breslow and Efron tied event-time approximations were evaluated. For covariate in replicate , the coefficient-level relative error was defined as
The replicate-level mean relative error was then defined as
When , reduces to the relative error for the single coefficient. Table 3 reports the median and maximum of across the simulated data sets.
The Cox validation results show close numerical agreement with the reference implementation. In float32, median MRE values were below in all scenarios, and the largest maximum
Antoine Poirot-Bourdain, Alexis Van Straaten, Emmanuel Bacry, Anne-Sophie Jannot, Jean Feyff
MRE was . In float64, median MRE values were below , and the largest maximum MRE was . These results indicate that coxphGPU() reproduces coxph() closely in double precision, while retaining small numerical discrepancies in the recommended float32 configuration.
WCE model validation. The WCE implementation was validated in two steps. First, unit tests compared wceGPU() from survivalGPU with the reference WCE() function from the WCE package on standard model specifications, including the construction of WCE-derived covariates, regression coefficients, variance estimates, partial log-likelihoods, information criteria, and hazard-ratio contrasts. Second, simulation-based comparisons were used to quantify numerical differences between wceGPU() and WCE() across randomly generated WCE scenarios.
For the simulation-based validation, each replicate combined a randomly selected weight-function scenario and a randomly selected target hazard ratio. The weight-function scenario was randomly selected from among the six non-null scenarios shown in Figure 8 of Appendix A. The target hazard ratio was randomly selected from the set , and the corresponding WCE coefficient was defined on the log-hazard-ratio scale as
Because the simulated weight functions are normalized over the 180-day lag window, this target hazard ratio can be interpreted as the hazard ratio comparing a patient receiving a constant unit dose during the full cutoff window with an otherwise identical unexposed patient. The cutoff was fixed at 180 days in all WCE validation analyses.
For each simulated data set, both unconstrained and right-constrained WCE specifications were fitted with wceGPU() and WCE() using 1, 2, and 3 interior knots. No model selection based on BIC was performed. Because the WCE model is estimated through spline coefficients rather than through a single exposure coefficient, validation focused on the standardized hazard-ratio contrast defined in Equation (13). This contrast compared a hypothetical patient receiving a constant unit dose during the entire 180-day cutoff window with a hypothetical patient receiving a dose of zero during the same window.
For each replicate and fitted specification, we computed the HR estimated by wceGPU() and the HR estimated by the reference WCE() function. The relative error for the HR contrast was defined as
Table 4 reports the median and maximum of this relative error across the simulated data sets, separately for unconstrained and right-constrained WCE specifications and for each number of interior knots.
The WCE validation results also show strong numerical agreement with the reference implementation. In float32, the median relative errors for the standardized HR contrast were all below , and the largest maximum relative error was . Thus, even in single precision, the discrepancy with WCE() remained below 0.3% in all tested spline specifications. In float64, the median relative errors were below , and all maximum relative errors
| Interior knots | Constraint | float32 | float64 | ||
|---|---|---|---|---|---|
| Median RE | Max RE | Median RE | Max RE | ||
| 1 | Unconstrained | ||||
| Right-constrained | |||||
| 2 | Unconstrained | ||||
| Right-constrained | |||||
| 3 | Unconstrained | ||||
| Right-constrained | |||||
Table 4: WCE model validation in float32 and float64. Comparison of wceGPU() from survivalGPU with the reference WCE() function from the WCE package across simulated WCE data sets of 1,000 patients. Results are reported separately for unconstrained and right-constrained WCE specifications and for models with 1, 2, and 3 interior knots. RE denotes the relative error for the standardized HR contrast defined in Equation (22).
were below . These results show that the survivalGPU WCE implementation reproduces the reference WCE estimates to very high numerical precision in double precision, while the recommended float32 GPU configuration retains small relative errors.
Overall, the validation results support the numerical reliability of survivalGPU for both Cox and WCE models. Double precision provides near-identical agreement with the reference implementations and is therefore useful for validation and sensitivity analyses. Single precision introduces slightly larger numerical differences, as expected, but these differences remained below 1% for all Cox and WCE validation scenarios. This supports the use of float32 as the recommended high-performance setting for the computational benchmarks and for large-scale GPU analyses.
6. Benchmarks
The objective of the benchmark study was to assess the computational gain provided by survivalGPU for fitting Cox and WCE models on data sets of increasing size.
Data generation. All benchmark data sets were generated using the simulation framework described in Appendix A. For all non-null simulation scenarios, the regression coefficient was fixed at . This value was used only for benchmark data generation and differs from the validation setting in Section 5.
Computational environment. All experiments were run on the same workstation, equipped with an Intel Xeon W-2255 CPU running at 3.70 GHz and an NVIDIA GeForce RTX 3090 GPU with 24 GB of memory. CPU computations were restricted to a single core and were not parallelized. The software environment consisted of Ubuntu 24.04.2 LTS, Python 3.13.0, R 4.3.3, CUDA 12.2, torch 2.8.0, KeOps 2.3, survival 3.5.8, WCE 1.0.3, lifelines 0.30.3, xgboost 3.2.0, and torchsurv 0.1.6.
A preliminary warm-up run was performed before timing GPU computations. For each benchmark configuration, the same simulated data set was fitted three times, and the reported runtime corresponds to the mean elapsed wall-clock time across these three runs. Runtime measurements excluded data simulation and package loading.
Floating-point precision. All benchmark experiments with survivalGPU were performed using float32 arithmetic. As discussed in Section 3, single precision is the recommended setting for GPU acceleration because it reduces memory requirements and generally improves runtime, especially on hardware with limited double-precision throughput. The validation study in Section 5 reports results for both float32 and float64, showing that float32 preserves close numerical agreement with the reference implementations while corresponding to the high-performance configuration used in the benchmarks.
Bootstrap runtime estimation. For bootstrap experiments, coxphGPU() and wceGPU() executed on the GPU were evaluated using their implemented bootstrap procedures. For the CPU backend of survivalGPU and for reference implementations that did not provide parallelized bootstrap support, total runtimes were extrapolated from the runtime of a single model fit. Because a bootstrap analysis with replicates requires fitting the model once on the original data set and once for each bootstrap sample, the extrapolated runtime was computed as
where is the mean runtime of one model fit over the three repeated runs and is the number of bootstrap replicates. In all bootstrap benchmarks, the number of bootstrap replicates was set to .
6.1. coxphGPU() function
Cox model benchmark. The GPU-accelerated coxphGPU() function from survivalGPU was compared with coxph() from the survival package and with the CoxPHFitter estimator from the lifelines package in Python. The benchmark used one time-dependent covariate and data sets containing 500 to 1,000,000 patients. For coxphGPU(), runtimes are reported for both CPU and GPU execution.

Figure 2: Benchmark results for Cox model fitting. Reported runtimes correspond to the mean elapsed time over three runs on the same simulated data set. Left: elapsed time across implementations. Right: speedup of coxphGPU() with GPU acceleration relative to the other implementations.
Figure 2 shows that GPU acceleration reduced the runtime of Cox model fitting for large data sets, although coxph() from survival was already very efficient. For small data sets, the fixed overhead of GPU execution dominated the computation time. As the sample size increased, however, the GPU version of coxphGPU() became increasingly advantageous. At
, coxphGPU() on the GPU required 2.75 seconds, compared with 15.35 seconds for coxph() from survival, 31.58 seconds for coxphGPU() on the CPU, and 131.26 seconds (2.19 minutes) for CoxPHFitter from lifelines. This corresponded to 5.6-fold, 11.5-fold, and 47.7-fold speedups relative to survival, the CPU backend of survivalGPU, and lifelines, respectively. These results indicate that GPU acceleration provides a clear gain for large data sets, while also showing that standard Cox model fitting is already computationally efficient.
Cox model benchmark with bootstrap resampling. We then evaluated runtimes when estimating confidence intervals using bootstrap replicates. The Cox bootstrap benchmark was performed up to patients. For the CPU backend of survivalGPU and for implementations without parallelized bootstrap support, runtimes were extrapolated according to Equation (23).

Figure 3: Benchmark results for Cox model fitting with bootstrap replicates. Reported runtimes correspond to the mean elapsed time over three runs on the same simulated data set. Runtimes for coxphGPU() on the GPU are measured using the implemented bootstrap procedure, whereas runtimes for the CPU backend of survivalGPU and for implementations without parallelized bootstrap support are extrapolated using Equation (23). Left: elapsed time across implementations. Right: corresponding speedup; values involving extrapolated runtimes represent projected speedups.
Figure 3 shows that bootstrap resampling amplified the advantage of GPU acceleration. For the smallest data sets, the overhead of launching and coordinating the GPU computation remained visible. For larger data sets, however, the parallelized bootstrap implementation in survivalGPU provided a substantial reduction in runtime. At , coxphGPU() on the GPU required 71.64 seconds (1.19 minutes), compared with 1,004.62 seconds (16.74 minutes) for the extrapolated survival runtime, 2,428.25 seconds (40.47 minutes) for the extrapolated runtime of coxphGPU() on the CPU, and 12,697.37 seconds (3.53 hours) for the extrapolated lifelines runtime. This corresponded to 14.0-fold, 33.9-fold, and 177.2-fold speedups relative to survival, the CPU backend of survivalGPU, and lifelines, respectively.
These results highlight the practical benefit of parallelized bootstrap computation for large-scale survival analysis. In particular, GPU acceleration makes bootstrap resampling procedures substantially more practical when confidence intervals must be estimated from a large number of replicates.
Comparison with other GPU-compatible Cox implementations. Finally, we compared coxphGPU() with alternative GPU-compatible approaches related to Cox-type survival objectives. The torchsurv package provides a Cox loss function designed for deep learning frameworks rather than a direct implementation of the Cox proportional hazards model. To obtain a comparable baseline, we combined this loss with an L-BFGS optimizer applied to a linear model with a single layer. The number of optimization iterations was limited to 20, which is consistent with the typical order of magnitude used in standard Cox model fitting.
The xgboost package also provides a survival objective, but does not implement the same Cox model formulation as coxph() from survival or coxphGPU() from survivalGPU. For comparability, the number of boosting iterations was restricted to 20, yielding the same nominal number of optimization or boosting steps. This comparison should therefore be interpreted as a computational baseline rather than a strict comparison of statistically identical model-fitting procedures.

Figure 4: Comparison of coxphGPU() from survivalGPU with alternative GPU-compatible Cox-type survival objectives. Reported runtimes correspond to the mean elapsed time over three runs on the same simulated data set.
Figure 4 shows that, for this time-invariant Cox benchmark, coxph() from survival and the survival objective from xgboost were faster than coxphGPU() on small data sets, where the fixed overhead of GPU execution dominated the computation time. As the sample size increased, this overhead became negligible, and at the largest sample size coxphGPU() was the fastest of the tested implementations. At , coxphGPU() required 0.70 seconds, compared with 0.86 seconds for coxph() from survival, 2.13 seconds for the survival objective from xgboost, and 788.97 seconds (13.15 minutes) for the Cox loss from torchsurv. This corresponded to 1.2-fold, 3.1-fold, and 1,134.5-fold speedups relative to survival, xgboost, and torchsurv, respectively. The large difference with torchsurv is expected because torchsurv is primarily designed for integration into deep learning pipelines, where the Cox loss is typically only one component of a larger neural network. Representing time-dependent covariates in torchsurv, when used, is memory-intensive and may lead to GPU memory overflow. The survival objective in xgboost does not support time-dependent covariates. Therefore, this comparison was restricted to time-invariant covariates.
6.2. Evaluation of the wceGPU() function
WCE model benchmark without bootstrap resampling. We then evaluated the runtime required to fit WCE models. The WCE benchmark used data sets ranging from 500 to 100,000 patients. For each data set, the WCE model was fitted with a cutoff of 180 days, nknots set to 3, and an unconstrained WCE specification.
The wceGPU() function accelerates the two main computational steps of the WCE model. The first step is the construction of the WCE-derived covariates based on the WCE spline basis. This step is the main computational bottleneck in the reference WCE() implementation from the WCE package. In survivalGPU, this operation is performed using KeOps, which allows efficient symbolic matrix operations without explicitly materializing the full matrices involved in the convolution. The second step is the maximization of the Cox partial likelihood once the WCE-derived covariates have been constructed.
As in the Cox benchmark, we report runtimes for survivalGPU for both CPU and GPU execution. This distinction makes it possible to separate the gain obtained from the survivalGPU implementation on the CPU from the additional gain obtained by executing the computations on the GPU.

Figure 5: Benchmark results for WCE model fitting. Reported runtimes correspond to the mean elapsed time over three runs on the same simulated data set. Left: elapsed time across implementations. Right: speedup of wceGPU() with GPU acceleration relative to the other implementations.
Figure 5 shows that the survivalGPU implementation substantially reduced the runtime of WCE model fitting for moderate and large data sets, both when executed on the CPU and when executed on the GPU. The CPU version of wceGPU() was already markedly faster than the reference WCE() implementation for large data sets, reflecting the efficiency of the KeOps-based construction of the WCE-derived covariates. GPU execution provided an additional gain, especially for the largest data sets. At , wceGPU() required 9.83 seconds on the GPU, compared with 204.07 seconds (3.40 minutes) on the CPU and 9,050.72 seconds (2.51 hours) for the reference WCE() implementation. This corresponded to 20.8-fold and 920.7-fold speedups relative to the CPU backend of survivalGPU and to WCE(), respectively.
These results indicate that both components of the implementation contribute to the overall acceleration: the memory-efficient construction of WCE-derived covariates removes the main bottleneck of the reference implementation, while GPU execution further accelerates large-scale model fitting. These gains are important in practice because WCE models are often fitted over a grid of hyperparameter values, including several spline complexities and constraint settings. Reducing the runtime of a single WCE fit therefore directly reduces the cost of model exploration and selection.
WCE model benchmark with bootstrap resampling. Finally, we evaluated the runtime of WCE estimation with patient-level bootstrap replicates. Bootstrap resampling is commonly used for WCE models to estimate confidence intervals for hazard-ratio contrasts. However, because each bootstrap replicate requires refitting the model, the computational cost can be high for large data sets. Using replicates provides a realistic assessment of the computational cost of bootstrap-based uncertainty estimation in WCE analyses.
For the CPU backend of survivalGPU and for implementations that did not provide parallelized bootstrap support, total runtimes were extrapolated using Equation (23) with . In survivalGPU, the WCE bootstrap procedure avoids recomputing WCE-derived covariates for each bootstrap sample. The WCE-derived covariates are computed once for the original design matrix and reused across bootstrap replicates, after which the Cox partial likelihood is refitted using bootstrap-specific resampling weights.

Figure 6: Benchmark results for WCE model fitting with bootstrap replicates. Reported runtimes correspond to the mean elapsed time over three runs on the same simulated data set. Runtimes for wceGPU() on the GPU are measured using the implemented bootstrap procedure, whereas runtimes for the CPU backend of survivalGPU and for implementations without parallelized bootstrap support are extrapolated using Equation (23). Left: elapsed time across implementations. Right: corresponding speedup; values involving extrapolated runtimes represent projected speedups.
Figure 6 shows that bootstrap resampling further increased the practical advantage of survivalGPU. The benefit was particularly strong for WCE models because the reference implementation requires repeated construction of WCE-derived covariates and repeated model fitting across bootstrap samples. In contrast, survivalGPU computes the WCE-derived covariates once and reuses them during the bootstrap procedure, substantially reducing the cost of resampling.
At , wceGPU() with GPU acceleration completed the bootstrap analysis in 5,021.78 seconds (1.39 hours). The extrapolated runtime was 205,089.98 seconds (2.37 days) for the
CPU backend of survivalGPU and 6,635,933.69 seconds (76.80 days) for the reference WCE() implementation. Thus, at this sample size, the GPU implementation was 40.8-fold faster than the extrapolated CPU backend of survivalGPU and 1,321.4-fold faster than the extrapolated reference implementation.
The CPU version of wceGPU() was already substantially faster than the reference implementation, reflecting the efficiency of the KeOps-based construction of the WCE-derived covariates, even when executed on the CPU. However, GPU acceleration provided an additional major gain for bootstrap resampling. Because the benchmark experiments were performed using the recommended float32 GPU configuration described in Section 3, these results represent the intended high-performance use case of survivalGPU. Together with the numerical validation reported in Section 5, they show that the combination of memory-efficient WCE-derived covariate construction, single-precision GPU arithmetic, and GPU-parallelized model fitting makes bootstrap estimation of confidence intervals feasible for large WCE analyses that would otherwise be computationally prohibitive.
7. Illustration
To illustrate the use of the survivalGPU package, we analyze the drugdata dataset from the WCE package. The data contain follow-up information for 500 patients, including time-varying drug exposure through the dose variable, event indicators, and baseline covariates such as age and sex. Note that the dataset contains one line per unit of follow-up time, defined by the Start and Stop variables, rather than one line per interval over which the covariates remain constant.
The objective of this example is not to draw substantive conclusions about a real drug effect, but to demonstrate a typical workflow using survivalGPU for the coxphGPU() and wceGPU() functions in R.
7.1. Analysis of the drugdata dataset with the coxphGPU() function
A Cox model considers each line of the dataset to be an independent patient in calculations. As the drugdata dataset contains one line per unit of time, it is not optimal for the Cox model. It is better to use a function like survcondense of the survival package to compress the dataset so it has only one line per interval over which the covariates remain constant. It will not change the results of the analysis but the computations will be quicker.
R> data("drugdata",package="WCE") R> compressed_drugdata <- survcondense( R> Surv(Start, Stop, Event) ~ age + sex + dose, R> data = drugdata, R> id = Id R> ) R> R> print(head(compressed_drugdata))
| ID | age | sex | dose | Start | Stop | Event | |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 40 | 1 | 0.0 | 0 | 14 | 0 |
| 2 | 1 | 40 | 1 | 2.0 | 14 | 21 | 0 |
|---|---|---|---|---|---|---|---|
| 3 | 1 | 40 | 1 | 0.0 | 21 | 28 | 0 |
| 4 | 1 | 40 | 1 | 2.5 | 28 | 49 | 1 |
| 5 | 2 | 48 | 0 | 0.0 | 0 | 14 | 0 |
| 6 | 2 | 48 | 0 | 1.5 | 14 | 63 | 0 |
coxphGPU is used almost like coxph from the survival package. The bootstraps are done using the bootstrap() function on the fitted Cox object. To use the bootstrap function it's necessary to save the design matrix of the data used by the model with the x = TRUE argument. It's also necessary to add the patient_id of the model, here the column "Id". Without it, the bootstrap function wouldn't be able to resample on different patients and the results would be meaningless. The batchsize argument sets the number of bootstraps run in parallel on the GPU. The summary is identical to the one in the survival package; however, if bootstraps were run, it adds the confidence intervals calculated with the bootstraps.
R> result <- coxphGPU(Surv(Start, Stop, Event) ~ dose + age + sex,
- data = compressed_drugdata,
- x = TRUE, patient_id = "Id", device = "gpu") R> result_boot <- bootstrap(result, R = 100, batchsize = 25) R> summary(result)
coef exp(coef) se(coef) z Pr(>|z|) dose 0.226072 1.253666 0.047500 4.759 1.94e-06 *** age 0.011103 1.011165 0.003966 2.800 0.00511 ** sex 0.627285 1.872519 0.117760 5.327 1.00e-07 ***
Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘’ 1
exp(coef) exp(-coef) lower .95 upper .95 dose 1.254 0.7977 1.142 1.376 age 1.011 0.9890 1.003 1.019 sex 1.873 0.5340 1.487 2.359
Concordance= 0.619 (se = 0.017) Likelihood ratio test= 55.44 on 3 df, p=6e-12 Wald test = 58.46 on 3 df, p=1e-12 Score (logrank) test = 59.94 on 3 df, p=6e-13
Confidence interval with 100 bootstraps for exp(coef), conf.level = 0.95 : 2.5% 97.5% dose 1.12260 1.36806 age 1.00466 1.02059 sex 1.50640 2.36081
The dose, the age and the sex all have a p-value of less than 0.05, so they are all significant.
We can see that the confidence intervals estimated by the model and by the bootstraps are very similar.
The function outputs a coxphGPU object constructed by S3 inheritance from the coxph object of the survival package. That means that all the functions of the package that can be used on a coxph object can be used on our result. Here, for example, we can test the proportional hazards assumption.
R> cox.zph(result)
| chisq | df | p | |
|---|---|---|---|
| dose | 2.08931 | 1 | 0.15 |
| age | 0.37223 | 1 | 0.54 |
| sex | 0.00116 | 1 | 0.97 |
| GLOBAL | 2.53698 | 3 | 0.47 |
No p-value is lower than 0.05, so the proportional hazards assumption is respected for all the covariates.
And as our coxphGPU object inherits the properties of the coxph object, we can also use the functions of other packages that work on a coxph object. For example, we can plot the adjusted survival curves from the Cox model using the survminer package.
R> library("survminer") R> ggadjustedcurves(result, variable = "sex", data = drugdata)
7.2. Analysis of the drugdata dataset with the wceGPU() function
In contrast to the Cox model, the WCE model cannot be fitted on a data set compressed into intervals over which the covariates remain constant. The hazard at time depends on the full exposure history through the WCE-derived covariates defined in Equation 15. These covariates change at every follow-up time, even during periods when the dose itself is constant. The data set must therefore contain one row per unit of follow-up time for each patient. The drugdata data set is already in this format, so no transformation is needed. For data sets recorded as intervals of constant exposure, the survSplit() function from the survival package can be used to expand them into one row per unit of follow-up time.
R> data("drugdata", package = "WCE") R> print(head(drugdata))
| ID | Event | Start | Stop | sex | age | dose | |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 0 | 1 | 1 | 40 | 0 |
| 2 | 1 | 0 | 1 | 2 | 1 | 40 | 0 |
| 3 | 1 | 0 | 2 | 3 | 1 | 40 | 0 |
| 4 | 1 | 0 | 3 | 4 | 1 | 40 | 0 |
| 5 | 1 | 0 | 4 | 5 | 1 | 40 | 0 |
| 6 | 1 | 0 | 5 | 6 | 1 | 40 | 0 |
Fitting a WCE model requires choosing three hyperparameters, described in Section 2.3: the cutoff, the number of interior knots and the boundary constraint.
The cutoff defines the time window over which past exposures are assumed to affect the current hazard, and should be chosen from prior knowledge of the drug. If the cutoff is too short, the estimated weight function cannot capture the full effect of past exposures. If it is too long, the spline knots are spread over a wider interval, and short-term effects are estimated less accurately. In this example, the cutoff is set to 180 days.
The nknots argument sets the number of interior knots of the cubic B-spline basis. Additional knots make the estimated weight function more flexible but increase the risk of overfitting. When a vector of candidate values is given to nknots, wceGPU() fits one model for each value and retains the model with the lowest BIC, defined in Equation (14).
The constrained argument determines whether the estimated weight function is forced to reach zero smoothly at the cutoff. If the cutoff is long enough to contain the full effect of past exposures, the true weight function is close to zero at the cutoff and the right constraint is appropriate. If the cutoff is too short, the true weight function is still nonzero at the cutoff, but the constraint forces the estimate to zero regardless. To assess whether the chosen cutoff is long enough, the model is fitted with and without the right constraint. If the unconstrained model has the lower BIC, it fits the data better, which suggests that the cutoff is too short. The summary() function give the result of the fitted model.
R> fit <- wceGPU( + data = drugdata, id = "Id", event = "Event", start = "Start", + stop = "Stop", expos = "dose", covariates = c("age", "sex"), + nknots = 1:3, cutoff = 180, constrained = "Right", x = TRUE +) R> summary(fit)
Weight function: cubic spline with 1 interior knot(s), constrained to go smoothly to zero
Covariates: coef exp(coef) se(coef) z Pr(>|z|) age 0.0118744 1.0119451 0.0039891 2.9767 0.002914 ** sex 0.7054766 2.0248115 0.1191675 5.9200 3.219e-09 ***
Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1
Partial log-likelihood: -1887.195, BIC: 3804.131 Number of events: 383
See plot(fit) for the estimated weight function.
Here the model corresponding to the lowest BIC is the model with one interior knot. It has a BIC of around 3804. It the model with a Right constraint. When launching the model without constraint, the BIC is 3812. It’s bigger than 3804 so that means that the cutoff is not too short.
Here the age and sex covaraites are both significative. However we don't have any information on the effect of the dose covariate modelled with the exposure. First we can see the coef for the wce-derived covaraites with the coef() function.
R> coef(result)
$est
| D1 | D2 | D3 | D4 | D5 | |
|---|---|---|---|---|---|
| [1,] | 0.03202082 | 0.002040809 | 0.005966648 | 0.01768173 | -0.0216031 |
$covariates
age sex
[1,] 0.01186158 0.7045086
The coef() method returns the estimated coefficients of the WCE-derived covariates and of the adjustment covariates. The largest coefficient corresponds to the first WCE-derived covariate, which suggests a strong short-term effect. However, the spline coefficients are difficult to interpret individually, because the shape of the weight function results from the combination of all basis functions. The estimated weight function can instead be visualized using the plot() method.
R> plot(model)

Figure 7: Estimated WCE weight function for the selected model fitted to the drugdata data set. The exposure cutoff is fixed at 180 days, and the model uses one interior knot and a right-constrained weight function.
Figure 7 shows that the most recent exposures receive the largest weights. The weights decrease sharply over the first 50 days, remain at a lower and roughly stable level until about 150 days, and then decrease to zero at the cutoff, as imposed by the right constraint.
Because the WCE metric depends on the full exposure history, the effect of the drug cannot be summarized by a single coefficient. Instead, hazard ratios are obtained by comparing two exposure histories, as defined in Equation (13). A simple contrast compares a patient exposed to one dose unit throughout the cutoff window with a patient who remains unexposed over the same window. This hazard ratio is computed with the HR() function.
R> exposed <- rep(1, cutoff) R> unexposed <- rep(0, cutoff) R> HR(fit, exposed, unexposed)
HR [1,] 4.534537
The estimated hazard ratio is 4.53, which indicates a strong association between exposure and the event. However, this estimate comes without a confidence interval. Wald-type inference on the WCE-derived covariates would be difficult to interpret, because it yields one p-value and one confidence interval for each spline coefficient rather than for the hazard ratio. It would also ignore the uncertainty introduced by the selection of the number of knots.
Confidence intervals for the hazard ratio are therefore obtained by patient-level bootstrap resampling, using the bootstrap() function. All candidate numbers of knots are fitted on each bootstrap sample, and the number of knots is selected again in each replicate, so that the confidence interval accounts for the uncertainty in this choice. As for the Cox model, the R argument sets the number of bootstrap replicates and the batchsize argument sets the number of replicates processed in parallel on the GPU.
R> fit_boot <- bootstrap(fit, R = 100, batchsize = 25) R> HR(fit_boot, exposed, unexposed)
HR CI 2.5% CI 97.5% [1,] 4.534537 3.345773 6.549886
The 95% bootstrap percentile confidence interval ranges from 3.35 to 6.55. Because it excludes 1, the association between exposure and the event is statistically significant at the 5% level. Since drugdata is a simulated data set, this result illustrates the output of survivalGPU rather than providing evidence about a real drug effect.
8. Conclusion and future work
survivalGPU provides a GPU-accelerated implementation of Cox and weighted cumulative exposure (WCE) models. It extends existing survival analysis software by combining compatibility with established R workflows and a Python interface. The package reproduces the results of the Cox routines from survival and of the WCE() function from the WCE package within precision-specific numerical tolerances in both float32 and float64, while substantially reducing computation time for large data sets and bootstrap-based estimation of confidence intervals.
The largest gains were observed when computations involved repeated model fitting. For the Cox model, GPU acceleration made coxphGPU() 5.6× faster than coxph() on 1,000,000 patients. With bootstrap replicates on 100,000 patients, coxphGPU() required 71.64 seconds (1.19 minutes), compared with an extrapolated runtime of 1,004.62 seconds (16.74 minutes) for coxph(), corresponding to a 14.0× speedup. For WCE models, the gains were larger: with 100,000 patients, wceGPU() required 9.83 seconds for a single model fit, compared with 9,050.72 seconds (2.51 hours) for the reference WCE() implementation, corresponding to a 920.7× speedup. With bootstrap replicates, wceGPU() required 5,021.78 seconds (1.39 hours), compared with an extrapolated runtime of 6,635,933.69 seconds (76.80 days) for WCE(), corresponding to a 1,321.4× speedup.
These speedups broaden the practical use of WCE models. Analyses that would previously require hours or days can be reduced to minutes, or seconds for single model fits, making it feasible to fit models over grids of hyperparameters, compare alternative constraints, and compute bootstrap confidence intervals on large cohorts. This is particularly important in pharmacoepidemiology, where exposure histories are longitudinal, often sparse, and may involve large cohorts.
A central component of these gains is the use of KeOps to compute the WCE-derived covariates used in the WCE model. This step represents the main bottleneck of the reference implementation. In survivalGPU, the memory-efficient formulation already provides substantial acceleration when executed on the CPU, while GPU execution adds a further speedup, especially for large data sets and bootstrap-based estimation of confidence intervals.
The design of survivalGPU emphasizes flexibility, extensibility, and long-term maintainability. The core implementation is written in Python and follows conventions used by scikit-learn, making it suitable for modern Python-based data science pipelines. At the same time, the R interface preserves a syntax familiar from coxph() in survival and WCE() in WCE, allowing the package to fit seamlessly into existing statistical and survival analysis workflows.
Future work will extend the current implementation to more complex WCE settings, including multiple concurrent exposures and exposure interactions. Because such extensions may increase model dimension, regularization methods will be incorporated to control overfitting and improve numerical stability. Additional Cox model extensions, including penalization, stratification, competing risks (Fine and Gray 1999), and automated variable selection (Tibshirani 1997), will also be considered.
These developments will be evaluated through simulation studies and applied to real-world pharmacoepidemiological data, in particular large healthcare databases such as the SNDS accessed through the Health Data Hub infrastructure. In this setting, survivalGPU may help make flexible WCE modeling more practical for the study of adverse drug reactions in patients exposed to complex treatment histories.
Acknowledgments
This work benefited from state aid managed by the Agence Nationale de la Recherche under France 2030, under reference “ANR-23-IACL-0008” (PR[AI]RIE-PSAI). It was also funded by EPI-PHARE under the 2021 call for projects.
References
Andalibi V, Christophe F, Laukkarinen T, Mikkonen T (2016). “Effective Connectivity Analysis in Brain Networks: A GPU-Accelerated Implementation of the Cox Method.” IEEE Journal of Selected Topics in Signal Processing, 10(7), 1226–1237. doi:10.1109/JSTSP.2016.2601820.
Bacry E, Bompaire M, Gaïffas S, Poulsen SV (2018). “tick: A Python Library for Statistical Learning, with a Particular Emphasis on Time-Dependent Modeling.” Journal of Machine Learning Research, 18(214), 1–5. URL https://jmlr.org/papers/v18/17-381.html.
Barnwal A, Cho H, Hocking TD (2022). “Survival Regression with Accelerated Failure Time Model in XGBoost.” Journal of Computational and Graphical Statistics, 31(4), 1292–1302. doi:10.1080/10618600.2022.2067548.
Cairat M, Severi G, Huybrechts I, Fournier A (2025). “Ingestion of Titanium Dioxide as an Excipient in Medicines and the Risk of Cancer: A Nationwide Study within the French National Health Data System.” European Journal of Epidemiology, 40(7), 833–843. doi:10.1007/s10654-025-01263-4.
Casarin R, Grassi S, Ravazzolo F, van Dijk HK (2015). “Parallel Sequential Monte Carlo for Efficient Density Combination: The DeCo MATLAB Toolbox.” Journal of Statistical Software, 68(3), 1–30. doi:10.18637/jss.v068.i03.
Charlier B, Feydy J, Glaunès JA, Collin FD, Durif G (2021). “Kernel Operations on the GPU, with Autodiff, without Memory Overflows.” Journal of Machine Learning Research, 22(74), 1–6. URL https://jmlr.org/papers/v22/20-275.html.
Clark TG, Bradburn MJ, Love SB, Altman DG (2003). “Survival Analysis Part I: Basic Concepts and First Analyses.” British Journal of Cancer, 89(2), 232–238. doi:10.1038/sj.bjc.6601118.
Cox DR (1972). “Regression Models and Life-Tables.” Journal of the Royal Statistical Society: Series B (Methodological), 34(2), 187–220. doi:10.1111/j.2517-6161.1972.tb00899.x.
Davidson-Pilon C (2019). “lifelines: Survival Analysis in Python.” Journal of Open Source Software, 4(40), 1317. doi:10.21105/joss.01317.
Dayan N, Beauchamp ME, Kountourides G, Pilote L, Abrahamowicz M (2026). “Weighted Cumulative Exposure Modelling to Assess the Association Between Reproductive Factors and Future Cardiovascular Disease in Women.” Paediatric and Perinatal Epidemiology, 40(2), 203–206. doi:10.1111/ppe.70029.
Efron B (1979). “Bootstrap Methods: Another Look at the Jackknife.” The Annals of Statistics, 7(1), 1–26. doi:10.1214/aos/1176344552.
Feydy J, Glaunès A, Charlier B, Bronstein MM (2020). “Fast Geometric Learning with Symbolic Matrices.” In Advances in Neural Information Processing Systems, volume 33, pp. 14448–14462. URL https://proceedings.neurips.cc/paper/2020/hash/a6292668b36ef412fa3c4102d1311a62-Abstract.html.
Fine JP, Gray RJ (1999). "A Proportional Hazards Model for the Subdistribution of a Competing Risk." Journal of the American Statistical Association, 94(446), 496–509. doi:10.1080/01621459.1999.10474144.
Kvamme H (2024). pycox: Survival Analysis with PyTorch. Python package version 0.3.0, URL https://github.com/havakv/pycox.
Mackenzie T, Abrahamowicz M (2002). "Marginal and Hazard Ratio Specific Random Data Generation: Applications to Semi-Parametric Bootstrapping." Statistics and Computing, 12(3), 245–252. doi:10.1023/A:1020750810409.
Maillard O, Bun R, Laanani M, Verga-Gérard A, Leroy T, Gault N, Estellat C, Noize P, Kaguelidou F, Sommet A, Lapeyre-Mestre M, Fourrier-Réglat A, Weill A, Quantin C, Tubach F (2024). "Use of the French National Health Data System (SNDS) in Pharmacoepidemiology: A Systematic Review in Its Maturation Phase." Therapies, 79(6), 659–669. doi:10.1016/j.therap.2024.05.003.
Monod M, Krusche P, Cao Q, Sahiner B, Petrick N, Ohlssen D, Coroller T (2024). "TorchSurv: A Lightweight Package for Deep Survival Analysis." Journal of Open Source Software, 9(104), 7341. doi:10.21105/joss.07341.
Paszke A, Gross S, Chintala S, Chanan G, Yang E, DeVito Z, Lin Z, Desmaison A, Antiga L, Lerer A (2017). "Automatic Differentiation in PyTorch." In NIPS 2017 Workshop on Autodiff. URL https://openreview.net/forum?id=BJJsrmfCZ.
Pazzagli L, Linder M, Zhang M, Vago E, Stang P, Myers D, Andersen M, Bahmanyar S (2018). "Methods for Time-Varying Exposure Related Problems in Pharmacoepidemiology: An Overview." Pharmacoepidemiology and Drug Safety, 27(2), 148–160. doi:10.1002/pds.4372.
Pölsterl S (2020). "scikit-survival: A Library for Time-to-Event Analysis Built on Top of scikit-learn." Journal of Machine Learning Research, 21(212), 1–6. URL https://jmlr.org/papers/v21/20-729.html.
Sapir-Pichhadze R, Laprise C, Beauchamp ME, Kaouache M, Zhang X, Della Vecchia A, Azoulay L, Franco EL, Abrahamowicz M, Nicolau B (2024). "Immunosuppression and Cancer Risk in Kidney Transplant Recipients: A Retrospective Cohort Study." International Journal of Cancer, 154(12), 2043–2053. doi:10.1002/ijc.34875.
Schwarz G (1978). "Estimating the Dimension of a Model." The Annals of Statistics, 6(2), 461–464. doi:10.1214/aos/1176344136.
Seabold S, Perktold J (2010). "statsmodels: Econometric and Statistical Modeling with Python." In Proceedings of the 9th Python in Science Conference, pp. 92–96. Austin, Texas. doi:10.25080/Majora-92bf1922-011.
Soeiro T, Uras M, Jouanjus É, Lapeyre-Mestre M, Micallef J (2025). "High-Dose Use of Pregabalin and Gabapentin in France: A Retrospective, Population-Based Cohort Study." The Lancet Regional Health – Europe, 57, 101424. doi:10.1016/j.lanepe.2025.101424.
Sundararajan M, Najmi A (2020). "The Many Shapley Values for Model Explanation." In Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pp. 9269–9278. PMLR. URL https://proceedings.mlr.press/v119/sundararajan20b.html.
Sylvestre MP, Abrahamowicz M (2009). "Flexible Modeling of the Cumulative Effects of Time-Dependent Exposures on the Hazard." Statistics in Medicine, 28(27), 3437–3453. doi:10.1002/sim.3701.
Sylvestre MP, Beauchamp ME, Kyle RP, Abrahamowicz M (2024). WCE: Weighted Cumulative Exposure Models. doi:10.32614/CRAN.package.WCE. R package version 1.0.3, URL https://CRAN.R-project.org/package=WCE.
Therneau TM (2024). survival: A Package for Survival Analysis in R. doi:10.32614/CRAN.package.survival. R package version 3.5-8, URL https://CRAN.R-project.org/package=survival.
Tibshirani R (1997). "The Lasso Method for Variable Selection in the Cox Model." Statistics in Medicine, 16(4), 385–395. doi:10.1002/(SICI)1097-0258(19970228)16:4<385::AID-SIM380>3.0.CO;2-3.
Wyplosz B, Fernandes J, Sultan A, Roche N, Roubille F, Loubet P, Fougère B, Moulin B, Duhot D, Vainchtock A, Raguideau F, Lortet-Tieulent J, Blanc E, Moïsi J, Goussiaume G (2022). "Pneumococcal and Influenza Vaccination Coverage among At-Risk Adults: A 5-Year French National Observational Study." Vaccine, 40(33), 4911–4921. doi:10.1016/j.vaccine.2022.06.071.
Yang J, Schuemie MJ, Ji X, Suchard MA (2024). "Massive Parallelization of Massive Sample-Size Survival Analysis." Journal of Computational and Graphical Statistics, 33(1), 289–302. doi:10.1080/10618600.2023.2213279.
A. Data simulation
A.1. The permutational algorithm
The simulated data sets used in this study were generated using the permutational algorithm, originally introduced by Mackenzie and Abrahamowicz (2002) for simulating time-to-event data under the Cox model framework and later adapted to the WCE model by Sylvestre and Abrahamowicz (2009). In the present work, we implemented a version based on the torch module in PyTorch, allowing the simulation step to be executed on the GPU, and used it to generate simulated data sets for validation and benchmarking.
The algorithm takes covariate trajectories, a set of observed follow-up times and event indicators, and a scenario defined by regression coefficients as inputs. For WCE simulations, it also takes an exposure trajectory , a weight function , and a WCE coefficient . For Cox simulations, the WCE term is omitted and the linear predictor depends only on Cox covariates.
The observed follow-up times are sorted in increasing order and matched sequentially to the covariate or exposure trajectories. At censoring times, an individual is sampled uniformly from the current risk set. At event times, an individual is sampled from the current risk set with probability proportional to , where is the linear predictor of the Cox or WCE model. The selected individual is then removed from all subsequent risk sets. In Cox-only scenarios, the WCE term is set to zero; when no additional Cox covariates are included, the Cox covariate term is set to zero. The detailed steps are presented in Algorithm 1.
Algorithm 1 Permutational algorithm for Cox and WCE simulations
1: Input:
- observed follow-up times and event indicators , where denotes an event and denotes censoring;
- model-specific covariate trajectories, including at least one of the following:
- exposure trajectories , a normalized weight function defined on , and a WCE coefficient ;
- Cox covariates , fixed or time-dependent, and their coefficients .
2: Output:
- individuals with covariate and exposure trajectories matched to observed follow-up times and event indicators.
3: If the scenario includes a WCE exposure, compute the WCE metric
4: Sort observed follow-up times and indicators:
5: for to do 6: Identify the risk set , defined as the individuals not yet assigned to a previous observed time. 7: if then 8: Draw individual uniformly at random from . 9: Assign censoring time to individual . 10: else 11: For all , compute
12: Draw individual from with probabilities . 13: Assign event time to individual . 14: end if 15: Remove from all subsequent risk sets. 16: end for
A.2. Simulation framework
General framework. The simulation framework used in this work closely follows the design of Sylvestre and Abrahamowicz (2009), which serves as a reference for the validation of the WCE model. The same permutational framework was also used to generate Cox model scenarios with fixed or time-dependent covariates.
Each patient was followed for at most 365 days. Marginal event times were generated independently of exposure and covariates from a uniform distribution on [0, 365] days. Random censoring times were generated independently from a uniform distribution on [0, 730] days, yielding approximately 50% censoring. The observed follow-up time was defined as the minimum of the event and censoring times, and the event indicator was equal to one if the event occurred before censoring.
WCE exposure trajectories. For WCE simulations, treatment exposure varied both between individuals and over time within individuals. Patients alternated between periods of treatment and periods of interruption. The duration of each treatment or interruption period was generated from a log-normal distribution with meanlog = log(0.5) and sdlog = 0.8, expressed in weeks and rounded up to the nearest week. This alternating process was repeated until the end of follow-up.
Within each uninterrupted treatment period, a constant daily dose was randomly assigned from the set {0.5, 1, 1.5, 2, 2.5, 3} and remained fixed throughout the period. During treatment interruptions, the dose was set to zero.
Cox covariate scenarios. For Cox simulations with a fixed covariate, each individual was assigned a binary covariate with equal probabilities for the two groups. The event probability was then driven by the Cox linear predictor , where is the log-hazard ratio specified for the simulation scenario.
For Cox simulations with a time-dependent covariate, the covariate trajectory was generated using the same intermittent mechanism as for the WCE exposure trajectories. However, in contrast to the WCE scenario, the current value entered the Cox linear predictor directly through , without convolution with a weight function.
For scenarios with ten covariates, this generation mechanism was repeated independently for each covariate, and the first coefficient was used for numerical validation. The same coefficient value was assigned to each simulated covariate.
The permutational algorithm was then used to match the observed follow-up times and event indicators to the simulated covariate and exposure trajectories according to the model-specific linear predictor.
Weight-function scenarios. Six non-null weight functions were used to evaluate numerical agreement across different weight-function shapes. Each non-null function was defined on the lag interval [0, 180] days, normalized so that , and set to zero for lags larger than 180 days. These scenarios represent different assumptions about how the effect of exposure changes with time since exposure, including monotonically decreasing, delayed, and approximately constant effects. The shapes of the weight functions are shown in Figure 8.
An additional null scenario was included by setting for all lags, so that exposure had no effect on the hazard. This null scenario was not normalized, since exposure was defined to have no effect.

Figure 8: Illustration of the six non-null weight functions used in the WCE simulation scenarios. Each function is normalized so that the area under its curve is equal to 1.
Affiliation:
Antoine Poirot-Bourdain CEntre de REcherche en MThématiques de la DÉcision CNRS-UMR 7534 Université Paris-Dauphine PSL 75016 Paris, France and HeKA Université Paris Cité INRIA INSERM F-75015, Paris, France
Alexis Van Straaten HeKA Université Paris Cité INRIA INSERM F-75015, Paris, France and Assistance Publique-Hôpitaux de Paris (AP-HP) Service d'informatique Médicale, Biostatistiques Et Santé Publique Hôpital Européen Georges Pompidou 75015 Paris, France
Emmanuel Bacry CEntre de REcherche en MThématiques de la DÉcision CNRS-UMR 7534 Université Paris-Dauphine PSL 75016 Paris, France
Anne-Sophie Jannot HeKA Université Paris Cité INRIA INSERM F-75015, Paris, France and Banque Nationale de Données Maladies Rares, Direction des Services Numériques AP-HP Paris, France
Jean Feydy HeKA Université Paris Cité INRIA INSERM F-75015, Paris, France