Summary
The identification of patient subgroups with comparable event-risk dynamics plays a key role in supporting informed decision-making in clinical research. In such settings, it is important to account for the inherent dependence that arises when individuals are nested within higher-level units, such as hospitals. Existing survival models account for group-level heterogeneity through frailty terms but do not uncover latent patient subgroups, while most clustering methods ignore hierarchical structure and are not estimated jointly with survival outcomes. In this work, we introduce a new framework that simultaneously performs patient clustering and shared-frailty survival modeling through a penalized likelihood approach. The proposed methodology adaptively learns a patient-to-patient similarity matrix via a modified version of spectral clustering, enabling cluster formation directly from estimated risk profiles while accounting for group membership. A simulation study highlights the proposed model’s ability to recover latent clusters and to correctly estimate hazard parameters. We apply our method to a large cohort of heart-failure patients hospitalized with COVID-19 between 2020 and 2021 in the Lombardy region (Italy), identifying clinically meaningful subgroups characterized by distinct risk profiles and highlighting the role of respiratory comorbidities and hospital-level variability in shaping mortality outcomes. This framework provides a flexible and interpretable tool for risk-based patient stratification in hierarchical data settings. Accompanying software is available at https://github.com/alessandragni/HazClust.
Keywords: clustering, frailty models, heterogeneity, penalization, survival analysis
1. INTRODUCTION
In real-world time-to-event datasets arising from clinical and epidemiological studies, identifying patients with similar risk trajectories enables the formation of subgroups, or clusters, characterized by shared likelihoods of experiencing key outcomes (eg death, relapse, treatment failure). Such stratification, relevant across a variety of application domains, in this setting can support clinical decision-making, facilitate disease subtyping, and advance precision-medicine initiatives (Collins and Varmus 2015). Nonetheless, patients are often intrinsically dependent, as they may share group membership—such as being treated in the same hospital—inducing correlations in outcomes and additional variability that must be accounted for in the analysis, as they can influence patients’ risk profiles in complex ways.
This scenario is common in healthcare applications and is exemplified by the project motivating our work, Enhance-Heart, a study conducted in the Lombardy region of Northern Italy, which was severely affected during the early stages of the COVID-19 pandemic due to an uncontrolled spread of SARS-CoV-2 infections (Alteri et al. 2021). This study focuses on patients with heart failure (HF) and aims, among other objectives, to investigate the complex relationship between patients’ clinical profiles and COVID-19-related mortality, while also accounting for differences across hospitals. Indeed, recent research has highlighted a significant interplay between heart failure and COVID-19 during the pandemic, with pre-existing HF complicating COVID-19 management and prognosis, and potentially leading to complications (Adeghate et al. 2021; Bader et al. 2021). Thus, identifying latent subgroups of HF patients hospitalized for COVID-19 while assessing how respiratory pathologies and overall healthcare condition influence mortality risk across patient clusters represents a key step in characterizing outcomes in a time-to-event framework. On the other hand, hospital-based resource availabilities, such as intensive care unit beds and general medicine/surgical beds, were found to be significantly associated with COVID-19 mortality incidence (Janke et al. 2021). Therefore, an accurate assessment of survival outcomes in this context requires modeling approaches capable of stratifying patient populations while accounting for differences across hospitals.
Traditional survival models often address heterogeneity arising from group-level dependence through a frailty term, that is a multiplicative factor in the hazard function, ie the risk of experiencing an event at a given time conditional on survival up to that point (Duchateau and Janssen 2008). This term can be specified in different ways, either parametrically—most commonly using Gamma or Lognormal distributions—or semiparametrically [see, eg Abrahantes et al. (2007); Balan and Putter (2020)]. However, these models often assume homogeneity within groups and overlook latent similar patterns between patients induced by their risk of experiencing an event of interest at a given time. Conversely, unsupervised stratification methods can reveal hidden patient subgroups by leveraging similarities across individuals; however, their limited integration with time-to-event outcomes often leads to suboptimal predictive performance. For example, Ahlqvist et al. (2018) performed a cluster analysis on 6 standardized clinical measures, identifying replicable diabetes subgroups with distinct prognoses and complication profiles. Advancing toward survival-informed clustering, Tosado et al. (2020) proposed transforming the feature space according to each feature’s association with survival (via martingale residuals) before applying clustering in this transformed space. Similarly, Chen et al. (2016) introduced a recursive partitioning algorithm that derives prognostic cancer staging systems by maximizing survival separation between groups of patients. Shifting the focus toward prediction, Chapfuwa et al. (2020) developed a Bayesian nonparametric framework that embeds subjects in a clustered latent space to enable accurate time-to-event predictions and subgroups with distinct risk profiles. Along related lines, Manduchi et al. (2021) presented a variational-autoencoder-based survival clustering approach that jointly leverages patient features and time-to-event outcomes, while Buginga and de Souza e Silva (2024) proposed a nonparametric mixture-of-experts model in which each expert captures a distinct subgroup’s survival distribution, thereby uncovering heterogeneous risk patterns. To the best of our knowledge, relatively few statistical models address the joint problem of clustering patients and modeling time-to-event outcomes while incorporating hierarchical structure. Among these, the cluster-weighted model of Caldera et al. (2025) is a recent approach that fits a shared frailty model within each cluster and models covariates with cluster-specific parametric distributions, factorizing the joint density via cluster-specific mixing weights. While promising, its reliance on strong distributional assumptions for the covariates may restrict its flexibility.
To address this gap, we propose a novel model that extends parametric shared frailty models to account for group membership (eg patients treated in the same hospital) while simultaneously estimating both patient cluster membership—defined by similar risk trajectories—and hazard function parameters via penalized likelihood optimization, where the resulting solution is obtained through an iterative procedure. Patient stratification is achieved through a modified version of spectral clustering approach following the strategies proposed in Nie et al. (2014, 2016) and Guo (2015), consisting in the adaptive estimation of a similarity matrix capturing patient-to-patient relationships representing the probability that patients are neighbors, based on their estimated hazard risk, combining frailty and covariate effects. At the end of the procedure, graph-theoretic principles ensure that the connected components of the resulting graph, represented by the learned similarity matrix, correspond exactly to the number of clusters.
Our model builds upon the framework proposed by Liu et al. (2022), originally developed for cancer subtyping, which integrates supervised graph-based clustering into the modeling of multi-omic tumor data through penalization terms embedded in a partial likelihood-based optimization scheme. Related extensions and applications of this approach have been explored in radiomics settings in Cavinato et al. (2023). A key advantage of this framework is that patient clustering is embedded directly within the optimization procedure, so that cluster assignments are guided by underlying risk dynamics and reflect distinct event hazard profiles, making them interpretable in terms of event risk. Building on this framework, our contribution is 2-fold:
-
(i)
We extend it to account for group-level (hospital) dependence, captured via a shared frailty term, together with patient-level heterogeneity (arising from subject-specific covariates and latent cluster membership) within a unified survival modeling framework;
-
(ii)
We propose a penalized full-likelihood approach that embeds patient clustering directly within the hazard model, allowing similarity structures to be learned in a risk-driven manner and producing clusters that are interpretable in terms of event risk.
This paper is organized as follows. Section 2 outlines the proposed methodology, detailing the notation and the estimation procedure. In Section 3, we present a simulation study designed to evaluate the performance of the proposed methodology. In Section 4, we describe the Enhance-Heart administrative database that motivated our work and report the main results obtained with our method. Finally, Section 5 provides concluding remarks, discusses the strengths and limitations of the proposed approach, and outlines directions for future work.
2. METHODOLOGY
In this section, we outline the methodology: a recap on notation for parametric frailty models (Section 2.1), the model description (Section 2.2), the model optimization (Section 2.3) and details related to the model selection procedure (Section 2.4).
2.1. Notation
Let the observed data be
, where units
are nested within groups
, and the total number of units is
. For each unit,
denotes the observed time to event or censoring, whichever comes first, and
indicates whether the event was observed (
) or censored (
). The covariate vector
may include both group-level and unit-specific components. We assume independent and noninformative censoring. To model the hazard rate of subject i in group g at time t , accounting for the presence of heterogeneity across groups, among the possible approaches (eg, fixed effects, stratified), we consider the shared frailty model (Duchateau and Janssen 2008)
![]() |
(2.1) |
where
is the vector of fixed-effect coefficients, the
’s,
, are the actual values of a random variable with probability density
, that is the frailty distribution, and
is the baseline hazard, assumed parametric, depending on the vector of parameters
, and
stands for the transpose. The cumulative hazard then follows as
, with
. Following computations in Section S1, the marginal loglikelihood can be expressed as
![]() |
(2.2) |
where
is the number of events in group g and
, being
the Laplace transform, for s≥ 0 , and r the order of derivative (Munda et al. 2012). Finally, it is known that the frailty term
can be predicted by
, being
the observed data in group g and
![]() |
(2.3) |
2.2. Model
In a parametric setting, such as that addressed by Munda et al. (2012), where both the frailty and the baseline hazard follow specified parametric distribution, the model parameters
can be estimated by maximizing the loglikelihood in (2.2), or minimizing the negative loglikelihood:
.
With the aim of performing clustering on the units while learning
and θ , let
be the affinity matrix whose entries
represent the similarity between the unit i in group g and the unit j in group h . Specifically, we interpret each entry
as the probability that unit i in group g has unit j in group h as a neighbor, imposing the constraint
, ∀ g, i that ensures that the connection probabilities for each unit sum up to 1. By assuming that units have a higher probability of being neighbors if they are more similar, or equivalently have a lower distance
, we rewrite the above optimization problem by further penalizing the loglikelihood for jointly estimating
, and
:
![]() |
(2.4) |
where
is the row of S corresponding to unit i in group g , and the reported inequality is elementwise. The last 2 terms in first line of (2.4) follow the literature on clustering with adaptive neighbors, see for instance Nie et al. (2014). These terms regulate the structure of neighborhood probabilities in
: the first term encourages higher probabilities for nearby units, that, if alone leads to the limit case of 1 for the nearest neighbor and 0 elsewhere, while the quadratic term promotes smoother and more evenly distributed assignments, with the limit case assigning equal probability 1/N to all units. Since the entries of
are unknown neighborhood probabilities to be estimated, the distance term provides the information driving their learning. Including it explicitly in the objective function enables joint estimation of the similarity structure and the survival model parameters. The hyperparameter γ controls the strength of the penalization; when γ = 0 , no penalization is applied, and consequently no clustering is induced, as the penalty and its associated constraints vanish. In contrast, μ is a tunable parameter that modulates the influence of the similarity structure in the overall optimization. Its selection will be discussed in Sections 2.3 and 2.4.
As we aim to learn
based on the similarity between the risk of experiencing the event of interest for patient i in group g , compared to patient j in group h , that we quantify on the log-hazard scale, as
and
, where the
shared across units cancels out in pairwise comparisons. Thus, we define
![]() |
(2.5) |
where
denotes the Euclidean distance, and
and
are the frailty terms defined in (2.3). These terms ensure that the distance captures between-group hazard differences: they cancel within a group but persist across groups, thereby encoding unobserved heterogeneity and promoting a similarity graph that aligns with frailty-adjusted risk profiles.
To perform clustering into C clusters, we interpret
as the adjacency matrix of a graph with the N units as nodes. In this setting, we define the Laplacian matrix
, where
is the diagonal degree matrix, where the gi -th entry is
. Following Mohar et al. (1991), the multiplicity C of the zero eigenvalue of
corresponds to the number of connected components in the graph with similarity matrix
. Enforcing
thus promotes a partition into C clusters. Intuitively, clustering corresponds to partitioning the similarity graph defined by
into groups of patients with comparable frailty-adjusted risk profiles, with membership given by the C connected components induced by the Laplacian rank constraint, as in spectral clustering. Furthermore, as shown in Nie et al. (2014) and Fan (1949), this rank constraint can be handled equivalently and more easily by introducing a matrix
, given that
![]() |
(2.6) |
being
the row of
corresponding to the belonging of unit i in group g .
Combining (2.2), (2.4), and (2.5), we get an optimization problem that reads
![]() |
(2.7) |
Following from (2.3), and noting that
, we apply a logarithmic property to obtain
![]() |
2.3. Optimization procedure
To solve the optimization problem in (2.7), we adopt a block coordinate descent approach: at each iteration, we update 1 block of variables while keeping the others fixed, until convergence. The procedure alternates among the following 3 steps:
Step 1
Fix
,
and update
. With
,
,
, and θ fixed, the update of
reduces to the following spectral optimization problem (Nie et al. 2014):
The factor 2λ does not affect the solution and can be omitted. The optimal
is obtained by taking the C eigenvectors of the Laplacian
associated with its C smallest eigenvalues. This step requires the number of clusters C and the current estimate of
.
Step 2
Fix
and update
. With
and
fixed, the optimization over
reduces to a survival modeling problem with an additional similarity-based regularization term. The optimization problem can be expressed as:
We estimate the survival model parameters relying on maximum likelihood optimization with parametric frailty, following Munda et al. (2012), and extend this framework with the similarity-based penalty. This step requires γ , the current similarity matrix
, the dataset and model specification.
Step 3
Fix
and update
. With
,
,
, and θ fixed, the update of
reads:
Using relation (2.6) and the separability of the problem across units, this reduces to an independent optimization for each
:
![]() |
(2.8) |
Let
be the sum of the first and third terms inside the parentheses of the objective in (2.8) and
. As shown in Section S2, problem (2.8) admits a closed-form solution for each row
:
subject to
, where
and
may differ across units.
By enforcing k -nearest-neighbor sparsity on
, ie allowing only the k nearest neighbors to connect unit i in group g , following Nie et al. (2014) and Guo (2015), letting
denote the sorted distances (excluding the self-distance), and imposing
, as shown in Section S3, we obtain
![]() |
(2.9) |
Finally, once all rows are updated, we set
. This step requires λ , k , the current estimate of
, the dataset and the model specification. Practical guidance on how to choose k is provided in Section S4.
Convergence is assessed based on both the stability of the similarity matrix and the quality of the statistical fit. Specifically, the algorithm terminates when all of the following conditions are satisfied: (i) the change in
between successive iterations is negligible; (ii) the improvement in log-likelihood is below a prescribed threshold; and (iii) the number of connected components in
equals the target C . If these conditions are not met, the procedure stops after a maximum number of iterations. Further computational details, including implementation settings and inference procedures, are provided in Section S5.
2.4. Model selection
To assess clustering quality across different model configurations (parametric distributions, γ , k , and C ), we use the silhouette coefficient (Kaufman and Rousseeuw 2009), a widely used measure balancing within-cluster cohesion and between-cluster separation. Given a unit i , let a(i) denote its average distance to all other units in the same cluster, and let b(i) be the minimum average distance from i to any other cluster. We recall that the silhouette value is defined as
, s(i)∈[-1,1] , with higher values indicating better separation. In our setting, distances for unit i with respect to units j are computed as
in (2.5), as it incorporates the covariate effects and the estimated frailty contributions. Group indices (such as g for i and h for j ) are omitted here since they play no role in the silhouette calculation. We then assess the overall clustering quality using the mean silhouette, and select the optimal clustering configuration as the one with the maximum mean silhouette, thereby achieving the best separation with respect to the fitted survival model.
3. SIMULATION STUDY
We here present a simulation study to assess the performance of the proposed methodology.
Aims
. Our main objectives are to evaluate, under varying penalization strengths ( γ ), the ability of the method (i) to correctly identify the underlying cluster structure, including the true number of clusters, and (ii) to accurately estimate model unknown parameters (
).
Data-generating mechanism
. We generate data by inducing the presence of
groups, each containing
(
), yielding a total sample size of
. To induce dependence among units within the same group, we introduce a group-level frailty
, drawn independently for each group from a Gamma distribution
, with θ = 0.5 so that
and
, inducing a moderate degree of within-group dependence.
Within each group g , every unit i is randomly assigned to one of the
latent clusters, denoted
. Each unit is associated with a covariate vector
and a linear predictor
where
is a vector of regression coefficients, so that, conditional on the cluster assignment
and frailty
, the linear predictor is modeled as
,
where
and σ = 1 . This specification generates clearly separated distributions of
across clusters, maximizing the clustering structure as measured in (2.5); additional scenarios, including weaker cluster separation, increased frailty variance, class imbalance, and model misspecification, are presented in Section S6.1. Finally, to preserve the intended simulation structure across clusters, we construct a single observed covariate
as
, setting
.
Survival times are generated under a Weibull baseline hazard, parameterized by
through
(
), ρ = 2.5 and ξ = 0.01 . The corresponding inverse cumulative hazard is
. Event times are generated using inverse transform sampling: we draw
and set
.
Censoring is imposed using 1 of 2 possible mechanisms: (i) administrative censoring at the fixed time of 100, and (ii) Gaussian (normal) censoring with mean 130 and standard deviation 15, analogous to defaults of genfrail in frailtySurv R package. Under this data-generating mechanism, the Kaplan–Meier curves highlight distinct patterns across the 3 clusters: one maintains high survival, another declines gradually, and a third drops sharply early on.
Estimands and performance measures . The primary targets of estimation are the cluster assignments and the vector of model parameters. Performance is assessed through:
-
•
Cluster identification, evaluated by the frequency with which convergence to the true number of clusters (
) is reached, and by the mean silhouette width (see Section 2.4). -
•
Clustering quality, assessed conditionally on correct identification of
, using the Adjusted Rand Index (ARI) (Hubert and Arabie 1985) and accuracy. The ARI, computed via scikit-learn, measures pairwise agreement between estimated and true partitions, adjusting for chance; it ranges from -0.5 (worse than chance) to 1 (perfect agreement), with 0 indicating random labeling. Accuracy measures the proportion of correctly classified observations. -
•
Parameter estimation, evaluated in terms of bias and variability of the estimated parameters, and summarized through boxplots.
Methods and implementation
. We use a grid search over
,
and
, generating
independent datasets for each configuration. The case γ = 0 corresponds to absence of penalization, so no clustering is performed, and just a parametric frailty model is fitted; in this case, C and k play no role in the estimation. Convergence is assessed using standard stopping criteria (tolS =
, tolll = 1, maxit = 200, see Section S5).
3.1. Results
3.1.1. Cluster identification
We primarily evaluate the ability of the method to correctly identify the underlying cluster structure, including the true number of clusters.
We first focus on the simulations obtained by superimposing
and γ > 0 . For both
and
, the method consistently identifies 3 clusters, with only minor differences in the γ thresholds at which performance begins to decline. Under administrative censoring, the method identifies the 3 clusters with 100% frequency for
. For larger γ , the identification rate decreases slightly, reaching a minimum of 95% at γ = 0.4 . Overall, convergence was achieved after an average of 17.49 iterations. Under normal censoring, perfect identification is maintained for
, after which the rate gradually slightly declines, reaching a minimum of 98% at γ = 0.4 . In this second case, the algorithm required on average 24.49 iterations to converge.
We further assess cluster identification ability using the mean silhouette width under varying choices of C , fixing
and
. The results, reported in Table 1, indicate that
yields the highest mean and median silhouette values under both censoring mechanisms, suggesting the best overall separation of clusters. Although the silhouette values for
exhibit slightly higher variability, the overall separation remains substantially stronger. Moreover, convergence to the selected number of clusters is always achieved for
, while this is not uniformly the case for alternative values of C .
Table 1.
Summary of the empirical distribution of the mean silhouette values (range in [-1,1] ) over
replications under 2 censoring mechanisms—(i) administrative and (ii) normal—for
and
. For each value of C , the table reports the mean, median, standard deviation, and the proportion of runs that converged to the selected C within maxit iterations. The estimates related to
are highlighted in bold.
| Censoring | C |
Mean silhouette
|
Convergence | ||
|---|---|---|---|---|---|
| Mean | Median | SD | % | ||
| (i) Administrative | 2 | 0.660 | 0.670 | 0.046 | 67 |
| 3 | 0.792 | 0.832 | 0.116 | 100 | |
| 4 | 0.661 | 0.718 | 0.121 | 100 | |
| 5 | 0.567 | 0.612 | 0.113 | 100 | |
| (ii) Normal | 2 | 0.618 | 0.649 | 0.082 | 93 |
| 3 | 0.670 | 0.789 | 0.182 | 100 | |
| 4 | 0.541 | 0.577 | 0.173 | 99 | |
| 5 | 0.466 | 0.484 | 0.145 | 100 | |
3.1.2. Clustering quality
We now evaluate clustering quality conditional on correct identification of
, using accuracy and the ARI. Results are reported in Table 2 across different censoring mechanisms, values of k and γ . Clustering performance is generally very high, especially for larger k , with accuracy and ARI frequently approaching 1. Specifically, the median values remain close to 1 across most settings, reflecting the skewed distribution of performance measures near the upper bound; the mean values, in contrast, show the gradual rise and the sharp drop more clearly: performance is slightly lower for very small γ , improves for intermediate values, and decreases sharply at γ = 0.4 , where penalization becomes much stronger. Standard deviations are very small when performance is high, indicating stable behavior across replications.
Table 2.
Empirical means, medians, and standard deviations of accuracy and ARI over
replications, evaluated under 2 censoring mechanisms—(i) administrative and (ii) normal—and across varying values of k and γ , setting
. The best estimates in each setting are highlighted in bold.
| Censoring | k | γ |
Accuracy
|
ARI
|
||||
|---|---|---|---|---|---|---|---|---|
| Mean | Median | SD | Mean | Median | SD | |||
|
0.971 | 1.000 | 0.089 | 0.942 | 1.000 | 0.161 | ||
|
0.971 | 1.000 | 0.089 | 0.942 | 1.000 | 0.161 | ||
|
0.975 | 1.000 | 0.081 | 0.950 | 1.000 | 0.147 | ||
| 20 | 0.01 | 0.957 | 1.000 | 0.082 | 0.908 | 1.000 | 0.172 | |
| 0.1 | 0.950 | 1.000 | 0.083 | 0.888 | 1.000 | 0.179 | ||
| 0.2 | 0.930 | 1.000 | 0.115 | 0.860 | 1.000 | 0.197 | ||
| 0.4 | 0.891 | 0.928 | 0.144 | 0.788 | 0.819 | 0.242 | ||
| (i) Administrative |
|
1.000 | 1.000 | 0.001 | 0.999 | 1.000 | 0.003 | |
|
1.000 | 1.000 | 0.001 | 0.999 | 1.000 | 0.003 | ||
|
1.000 | 1.000 | 0.001 | 0.999 | 1.000 | 0.003 | ||
| 50 | 0.01 | 1.000 | 1.000 | 0.001 | 0.999 | 1.000 | 0.004 | |
| 0.1 | 0.996 | 1.000 | 0.023 | 0.989 | 1.000 | 0.054 | ||
| 0.2 | 0.945 | 0.998 | 0.120 | 0.897 | 0.994 | 0.199 | ||
| 0.4 | 0.420 | 0.390 | 0.109 | 0.060 | 0.019 | 0.159 | ||
|
0.902 | 0.998 | 0.142 | 0.811 | 0.994 | 0.246 | ||
|
0.904 | 0.998 | 0.138 | 0.810 | 0.994 | 0.251 | ||
|
0.891 | 0.970 | 0.141 | 0.788 | 0.918 | 0.243 | ||
| 20 | 0.01 | 0.896 | 0.998 | 0.149 | 0.807 | 0.994 | 0.239 | |
| 0.1 | 0.913 | 1.000 | 0.117 | 0.820 | 1.000 | 0.224 | ||
| 0.2 | 0.922 | 0.998 | 0.097 | 0.831 | 0.994 | 0.195 | ||
| (ii) Normal | 0.4 | 0.870 | 0.894 | 0.145 | 0.752 | 0.732 | 0.237 | |
|
0.990 | 1.000 | 0.040 | 0.976 | 1.000 | 0.094 | ||
|
0.990 | 1.000 | 0.040 | 0.977 | 1.000 | 0.094 | ||
|
0.990 | 1.000 | 0.041 | 0.976 | 1.000 | 0.096 | ||
| 50 | 0.01 | 0.998 | 1.000 | 0.016 | 0.994 | 1.000 | 0.034 | |
| 0.1 | 0.994 | 1.000 | 0.027 | 0.986 | 1.000 | 0.060 | ||
| 0.2 | 0.964 | 0.998 | 0.089 | 0.922 | 0.994 | 0.183 | ||
| 0.4 | 0.417 | 0.386 | 0.102 | 0.056 | 0.015 | 0.148 | ||
Additional simulation settings are reported in Section S6.1. Overall, results suggest that the proposed approach is robust across the scenarios considered, and consistently outperforms a benchmark based on a 2-stage procedure, with performance declining mainly when the clustering signal is weak or the class balance is severely distorted.
3.1.3. Parameter estimation
Finally, we evaluate parameter estimation accuracy focusing on the case
, and restricting the attention to
to ease visualization and reduce the number of scenarios presented. We examine the estimates of the unknown parameters in the shared frailty model,
(with
); for completeness, we also include the unpenalized case γ = 0 , corresponding to a standard parametric frailty model. Figures 1 and S6.1 (in Section S6.2) report boxplots of the estimated parameters across different values of γ under administrative and normal censoring, respectively. The true parameter values are indicated by horizontal dashed lines. As expected, the bias generally increases with γ . In particular, θ exhibits slight underestimation even in the unpenalized case, consistent with previous findings based on the parfm implementation (Munda et al. 2012). Most parameters show stable variability across penalization levels, with the exception of ξ , which becomes increasingly variable as γ increases. To further quantify the effects of penalization on estimation accuracy, Section S6.3 analyzes the variance and mean squared error-to-variance ratio across all γ values and censoring schemes.
Figure 1.

Boxplots of parameter estimates for (a) θ , (b) ρ , (c) ξ , and (d) β across penalization levels γ (x-axis) under administrative censoring for
and
. The true parameter values are shown as a piecewise-constant horizontal line.
4. CASE STUDY
This section applies the proposed methodology to the Enhance-Heart dataset, a large administrative dataset linked with the COVID-19 registry (https://www.dati.lombardia.it/) of Lombardy Region (LR in the following).
4.1. Cohort selection
Sourcing from the administrative dataset related to the Enhance-Heart project, we select those patients that between 1 January 2018, and 31 December 2020 were diagnosed with HF, that is, hospitalized or visited emergency room under DRG code 127 (“Heart Failure and Shock”) according to the LR MS-DRG v40 system, thus including both primary/secondary diagnoses of HF (ICD-9-CM: 428.xx) and related conditions (ICD-9-CM: 402.01, 402.11, 402.91). Among these, we retain those hospitalized for COVID-19 according to a binary flag provided in the database, between 31 January 2020 (start of the national COVID-19 state of emergency in Italy) and 18 June 2021 (implementation of the Green Pass regulations governing reopening). For those patients, outcomes are assessed over a 90-d follow-up period; death within this window is considered the event, while patients surviving beyond are regarded as censored (55.25% of the sample).
The analysis is restricted to hospitals with a minimum of 50 patients hospitalized, as smaller hospitals may exhibit different organizational conditions and characteristics, and to ensure more robust results for the frailty-related estimates. We further exclude patients who required hospital transfers for medical purposes or who had multiple episodes of infection. The final cohort includes N = 3086 HF patients hospitalized for COVID-19 in M = 32 different hospitals in the LR.
The time-to-event outcome is defined by the pair (Time, Status), where Time denotes days until all-cause death within the 90-d observation window or censoring, and Status indicates event occurrence through a binary variable, equal to 1 if death from any cause occurs within the observation period, 0 otherwise. Patient’s covariates include Age at admission, Gender, and Modified Multisource Comorbidity Score (ModMCS) (Corrao et al. 2017; Caldera et al. 2025), a measure of overall comorbidity burden unrelated to the primary diagnosis and a proxy for general health status, with higher values reflecting greater nonrespiratory comorbidity burden. To complement this, we captured specific respiratory conditions separately using a binary indicator, Resp, which equals 1 if a patient presents with more than one of the following conditions: chronic obstructive pulmonary disease, bronchitis, pneumonia, or respiratory failure. See Table S7.1 for detailed variable descriptions and summary statistics.
4.2. Model setup
We fit our model under multiple configurations and identify the optimal one as that with the maximum mean silhouette value, as described in Section 2.4 (Kaufman and Rousseeuw 2009). Specifically, we consider 2 choices for the frailty distribution (Gamma and Inverse Gaussian) and 2 options for the baseline hazard distribution (Weibull and Exponential). We evaluate models with
,
, and
. We set maxit = 200, tolS =
, tolll = 1 and leave all the other parameters with default settings. The mean silhouette values for all the above configurations are reported in Table S7.2.
We select the model with the frailty distributed as Inverse Gaussian, the baseline as Weibull,
,
and
as the optimal clustering configuration, as it yields the highest mean silhouette score equal to 0.609 and therefore the best separation.
4.3. Results
With the chosen model, we obtain the following regression coefficients:
,
,
, and
. The correspondingP-values are all < 0.05 , indicating statistically significant effects. The estimated frailty variance is θ = 0.573 , while the Weibull parameters were ρ = 0.618 and
, respectively, following parametrization in Tables S5.1 and S5.2. The model reaches convergence in 23 iterations.
The resulting clusters—corresponding to disconnected components of the learned patient similarity graph—contain 1077, 1054, and 955 patients respectively. Cluster 1, the largest, comprises the oldest patients with the highest comorbidity burden and shortest mean follow-up; Cluster 2 includes slightly younger patients with the highest respiratory burden; Cluster 3 comprises the youngest patients with the lowest comorbidity and respiratory burden and the longest mean follow-up. All between-cluster differences are statistically significant (
; Table 3).
Table 3.
Characteristics of the identified patient clusters with respect to variables described in Section 4.1 and summarized in Table S7.1. Continuous variables are summarized as mean (SD) and categorical variables as percentage. Statistical differences among clusters were assessed using one-way ANOVA, Kruskal–Wallis, or chi-square tests, depending on the variable type and distribution. Reported P-values correspond to the comparison across all 3 clusters.
| Cluster 1 | Cluster 2 | Cluster 3 | P-value | |
|---|---|---|---|---|
| Number of patients | 1077 (34.89%) | 1054 (34.15%) | 955 (30.94%) | … |
| Age at admission in years | 83.5 (7.7) | 81.8 (7.8) | 78.4 (8.6) | < 0.001 |
| Chronic disease burden score (ModMCS) | 12.6 (8.5) | 11.8 (7.7) | 9.8 (6.7) | < 0.001 |
| Respiratory disease presence (Resp) | 0.99 (1.17) | 1.03 (1.21) | 0.87 (1.14) | 0.005 |
| Survival/observation time | 0.15 (0.10) | 0.16 (0.10) | 0.18 (0.10) | < 0.001 |
| Male sex (Gender = male) | 62.0% | 57.4% | 47.1% | < 0.001 |
| All-cause mortality (Status = 1) | 51.4% | 45.3% | 36.6% | < 0.001 |
The estimated survival curves in Fig. 2a reveal clear separation across the 3 clusters: Cluster 3 exhibits the most favorable and homogeneous prognosis, Cluster 1 the steepest decline and widest spread, and Cluster 2 occupies an intermediate position. Kaplan–Meier curves confirm this separation with a highly significant log-rank test (
, Fig. S7.1). At the hospital level, Fig. 2b reveals a strong association between posterior frailty estimates
and dominant cluster membership. Hospitals predominantly composed of Cluster 3 patients concentrate on the left of the frailty ranking (
), indicating a protective institutional effect, whereas hospitals dominated by Cluster 1 patients appear on the right (
), reflecting excess risk beyond that explained by observed covariates. While intrahospital heterogeneity in cluster composition exists, a dominant cluster is consistently identifiable within each hospital: 13 hospitals (40.6%) showed strong single-cluster predominance ( ≥ 80% of patients), of which 5 were entirely associated with 1 cluster, while only 3 hospitals exhibited a truly mixed composition with no cluster exceeding 60%.
Figure 2.

Case study results. a) Model-based estimated survival curves for each patient (thin lines), colored by cluster assignment, with the cluster specific average survival overlaid. b, top) Posterior frailty estimates
for each hospital, ranked by increasing frailty, colored by dominant cluster; point size reflects the percentage of patients belonging to the dominant cluster. b, bottom) Cluster composition of each hospital, ordered as in the top panel. c), d) Violin plots with overlaid boxplots showing the distribution of c) the total log-hazard contribution and d) the fixed-effects linear predictor only, across the 3 clusters.
Finally, Fig. 2c and d illustrate the 2 sources of risk driving the stratification. The covariate-driven term
already shows modest separation across clusters, with Cluster 1 patients carrying slightly higher baseline risk; however, the distributions overlap considerably. Once the hospital-level frailty shift
is incorporated, the separation becomes sharp and nearly complete, confirming that hospital-level heterogeneity—captured by the frailty parameter θ —substantially amplifies the risk separation beyond observed covariates.
5. DISCUSSION
Motivated by the need to identify latent patient subgroups in hierarchical time-to-event data, in this work we propose a framework that jointly performs patient risk-based clustering and survival modeling while accounting for group-level dependence through a parametric shared frailty model, ensuring that cluster assignments are informed by underlying survival dynamics. From a methodological perspective, our approach addresses a gap in the existing literature by jointly modeling survival outcomes, latent patient subgroups, and group-level dependence within a single likelihood-based framework, allowing patient stratification to emerge from estimated risk profiles while properly accounting for within-hospital correlation.
The simulation study demonstrates that the proposed methodology reliably recovers latent cluster structures across a broad range of settings. In particular, the results indicate that cluster recovery is driven primarily by the strength of the underlying clustering signal—namely, the degree of separation between cluster-specific risk profiles and the balance of latent cluster sizes—whereas the magnitude of the frailty variance has only a limited impact on performance, as it is well captured by the model. Because the proposed clustering procedure relies on a parametric shared frailty model, the resulting similarity structure depends on the assumed frailty and baseline hazard distributions. Nevertheless, the simulation experiments show that the methodology remains robust under misspecification of both the frailty distribution and the baseline hazard function, with only limited deterioration in clustering performance even under joint misspecification, and with accurate estimation of the parameters of the parametric frailty model when penalization is appropriately tuned.
When applied to the Enhance-Heart cohort of HF patients hospitalized for COVID-19, the method identifies 3 clinically interpretable clusters with distinct risk profiles, differing significantly in age, comorbidity burden, respiratory conditions, and survival trajectories (
), uncovering heterogeneity in event-time risk that would remain hidden under more standard approaches. Beyond patient-level stratification, the nonnegligible frailty dispersion parameter θ = 0.573 suggests that latent hospital factors—such as resource availability, clinical protocols, or pandemic-specific pressures—influence survival outcomes beyond observed covariates. These findings support the joint use of clustering and frailty as complementary tools for disentangling patient- and hospital-level sources of heterogeneity in time-to-event data.
Some limitations warrant consideration. First, the construction of the similarity graph relies on the choice of the neighborhood size k , which influences graph sparsity and cluster formation. Although adaptive tuning of the penalization parameter λ embedded in the algorithm mitigates this issue in practice, the relationship between k and the target number of clusters C remains an area for further investigation. Furthermore, each unit is forced to connect to its k nearest neighbors regardless of whether these lie near the cluster core or at its boundary. This limitation has been noted in the spectral clustering literature (Cai et al. 2022), where pruning weak connections and modifying the optimization term through power-function asymptotics have been proposed as potential remedies. However, such approaches introduce alternative tuning parameters, such as the maximum neighborhood size, without yielding performance improvements in our setting.
Moreover, the proposed method does not explicitly account for confounding or informative selection mechanisms through causal inference techniques. The identified clusters should therefore be interpreted as descriptive risk-based stratifications conditional on the observed data and the assumed model, rather than as causally defined subgroups. Residual unmeasured heterogeneity is nevertheless partially mitigated through the shared frailty term, which absorbs latent variation linked to the hierarchical structure of the data, and through the restriction of the analysis to a relatively homogeneous population, which reduces heterogeneity in the selection mechanism.
In addition, in the current framework, a common baseline hazard is assumed across clusters, which is simplified in the penalization distance, while heterogeneity is captured through covariates and frailty terms. Future work will aim to extend the model to allow cluster-specific baseline hazards, enabling a more nuanced characterization of risk dynamics across patient subgroups, although this would imply the definition of a time-dependent similarity measure. This extension would require reconsidering the frailty structure—as different clusters would have distinct frailties—and is beyond the scope of the present work. Additional developments could explore alternative similarity measures (eg via survival functions), as well as extensions to semi-parametric or fully nonparametric baseline hazards, further increasing the model’s flexibility.
Supplementary Material
Acknowledgments
This work is part of the Enhance-Heart project. Data were provided by “Unità Organizzativa Osservatorio Epidemiologico Regionale” and ARIA S.p.A. The authors acknowledge the support of MUR, grant Dipartimento di Eccellenza 2023-2027. Simulations were run on the Department of Mathematics HPC Cluster at Politecnico di Milano, funded by the same grant. We thank the associate editor and two anonymous reviewers for their helpful feedback, which helped us improve our manuscript.
Contributor Information
Alessandra Ragni, MOX, Department of Mathematics, Politecnico di Milano, Piazza Leonardo da Vinci 32, Milan 20133, Italy.
Lara Cavinato, MOX, Department of Mathematics, Politecnico di Milano, Piazza Leonardo da Vinci 32, Milan 20133, Italy.
Francesca Ieva, MOX, Department of Mathematics, Politecnico di Milano, Piazza Leonardo da Vinci 32, Milan 20133, Italy; Health Data Science Centre, Human Technopole, Viale Rita Levi–Montalcini 1, Milan 20157, Italy.
Supplementary material
Supplementary material is available at Biostatistics Journal online.
Funding
A.R. and L.C. are funded by the National Plan for NRRP Complementary Investments “ANTHEM - AdvaNced Technologies for Human-centrEd Medicine” (PNC0000003).
Conflicts of interest
None declared.
Data Availability
Software in the form of R code is available at https://github.com/alessandragni/HazClust. Data were provided by the Lombardy Region under permission and cannot be made publicly available for privacy reasons.
References
- Abrahantes JC et al. 2007. Comparison of different estimation procedures for proportional hazards model with random effects. Comput Stat Data Anal. 51:3913–3930. 10.1016/j.csda.2006.03.009 [DOI] [Google Scholar]
- Adeghate EA, Eid N, Singh J. 2021. Mechanisms of covid-19-induced heart failure: a short review. Heart Fail Rev. 26:363–369. 10.1007/s10741-020-10037-x [DOI] [PMC free article] [PubMed] [Google Scholar]
- Ahlqvist E et al. 2018. Novel subgroups of adult-onset diabetes and their association with outcomes: a data-driven cluster analysis of six variables. Lancet Diabetes Endocrinol. 6:361–369. 10.1016/S2213-8587(18)30051-2 [DOI] [PubMed] [Google Scholar]
- Alteri C et al. 2021. Genomic epidemiology of sars-cov-2 reveals multiple lineages and early spread of sars-cov-2 infections in Lombardy, Italy. Nat Commun. 12:434. 10.1038/s41467-020-20688-x [DOI] [PMC free article] [PubMed] [Google Scholar]
- Bader F, Manla Y, Atallah B, Starling RC. 2021. Heart failure and covid-19. Heart Fail Rev. 26:1–10. 10.1007/s10741-020-10008-2 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Balan TA, Putter H. 2020. A tutorial on frailty models. Stat Methods Med Res. 29:3424–3454. 10.1177/0962280220921889 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Buginga G, de Souza e Silva E. 2024. Clustering survival data using a mixture of non-parametric experts [preprint], arXiv, arXiv:2405.15934.
- Cai Y, Huang JZ, Yin J. 2022. A new method to build the adaptive k-nearest neighbors similarity graph matrix for spectral clustering. Neurocomputing. 493:191–203. 10.1016/j.neucom.2022.04.030 [DOI] [Google Scholar]
- Caldera L et al. 2025. Cluster-weighted modeling of lifetime hierarchical data for profiling covid-19 heart failure patients [preprint], arXiv, arXiv:2507.12230.
- Cavinato L et al. 2023. Explainable domain transfer of distant supervised cancer subtyping model via imaging-based rules extraction. Artif Intell Med. 138:102522. 10.1016/j.artmed.2023.102522 [DOI] [PubMed] [Google Scholar]
- Chapfuwa P, Li C, Mehta N, Carin L, Henao R. 2020. Survival cluster analysis. In: Proceedings of the ACM Conference on Health, Inference, and Learning (CHIL '20). New York, NY, USA: Association for Computing Machinery, 60–68. 10.1145/3368555.3384465 [DOI]
- Chen D et al. 2016. An algorithm for creating prognostic systems for cancer. J Med Syst. 40:160. 10.1007/s10916-016-0518-1 [DOI] [PubMed] [Google Scholar]
- Collins FS, Varmus H. 2015. A new initiative on precision medicine. N Engl J Med. 372:793–795. 10.1056/NEJMp1500523 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Corrao G et al. 2017. Developing and validating a novel multisource comorbidity score from administrative data: a large population-based cohort study from Italy. BMJ Open. 7:e019503. 10.1136/bmjopen-2017-019503 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Duchateau L, Janssen P. 2008. The frailty model. Springer. [Google Scholar]
- Fan K. 1949. On a theorem of Weyl concerning eigenvalues of linear transformations I. Proc Natl Acad Sci USA. 35:652–655. 10.1073/pnas.35.11.652 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Guo X. 2015. Robust subspace segmentation by simultaneously learning data representations and their affinity matrix. In Proceedings of the 24th International Conference on Artificial Intelligence (IJCAI'15). AAAI Press, 3547–3553.
- Hubert L, Arabie P. 1985. Comparing partitions. J Classif. 2:193–218. 10.1007/BF01908075 [DOI] [Google Scholar]
- Janke AT et al. 2021. Analysis of hospital resource availability and covid-19 mortality across the United States. J Hosp Med. 16:211–214. 10.12788/jhm.3539 [DOI] [PMC free article] [PubMed] [Google Scholar]
- Kaufman L, Rousseeuw PJ. 2009. Finding groups in data: an introduction to cluster analysis. John Wiley & Sons. [Google Scholar]
- Liu C et al. 2022. Supervised graph clustering for cancer subtyping based on survival analysis and integration of multi-omic tumor data. IEEE/ACM Trans Comput Biol Bioinform. 19:1193–1202. 10.1109/TCBB.2020.3010509 [DOI] [PubMed] [Google Scholar]
- Manduchi L et al. 2021. A deep variational approach to clustering survival data. In International Conference on Learning Representations (ICLR 2022). https://openreview.net/forum?id=RQ428ZptQfU
- Mohar B, Alavi Y, Chartrand G, Oellermann O. 1991. The Laplacian spectrum of graphs. Graph Theory Combinatorics Appl. 2:12. [Google Scholar]
- Munda M, Rotolo F, Legrand C. 2012. parfm: Parametric frailty models in r. J Stat Soft. 51:1–20. 10.18637/jss.v051.i11 [DOI] [Google Scholar]
- Nie F, Wang X, Huang H. 2014. Clustering and projected clustering with adaptive neighbors. In Proceedings of the 20th ACM SIGKDD international conference on Knowledge discovery and data mining (KDD '14). New York, NY, USA: Association for Computing Machinery, 977–986. 10.1145/2623330.2623726 [DOI]
- Nie F, Wang X, Jordan MI, Huang H. 2016. The constrained Laplacian rank algorithm for graph-based clustering. AAAI 2016. In: Proceedings of the 30th AAAI Conference on Artificial Intelligence. AAAI Press. p. 1969–1976.
- Tosado J et al. 2020. Clustering of largely right-censored oropharyngeal head and neck cancer patients for discriminative groupings to improve outcome prediction. Sci Rep. 10:3811. 10.1038/s41598-020-60140-0 [DOI] [PMC free article] [PubMed] [Google Scholar]
Associated Data
This section collects any data citations, data availability statements, or supplementary materials included in this article.
Supplementary Materials
Data Availability Statement
Software in the form of R code is available at https://github.com/alessandragni/HazClust. Data were provided by the Lombardy Region under permission and cannot be made publicly available for privacy reasons.































