## 6.2 Algortihm

$$k$$-survival curves algorithm

1. With $$\{(\widetilde{T}_{ij}, \Delta_{ij})$$, $$i=1, \ldots, n_j$$}, $$j = 1, \ldots, J$$, and using the Kaplan-Meier estimator obtain $$\hat S_j$$.

2. Initialize with $$K = 1$$ and test $$H_0(K)$$:

• Obtain the best" partition $$G_1, \ldots, G_K$$ by means of the $$k$$-means or $$k$$-medians algorithm.

• For $$k = 1, \ldots, K$$, estimate $$M_k$$ and retrieve the test statistic $$D$$.

• Generate $$B$$ bootstrap samples and calculate $$D^{\ast b}$$, for $$b = 1, \ldots, B$$.

• $$D > D^{\ast (1-\alpha)}$$
• reject $$H_0(K)$$
• $$K = K + 1$$
• go back to the beginning of current section

else
• accept $$H_0(K)$$ end

1. The number $$K$$ of groups of survival curves is determined.