# Phase-Type Survival Trees to Model a Delayed Discharge and Its Effect in a Stroke Care Unit
## 2 Materials and Methods
### Phase Type Survival Tree (PHTST)  
Phase-type distributions are a preferred choice to fit the spell length of stay data [62; 63], thanks to their memoryless property and ability to provide an intuitive description of the patient flow in a care system. A PHTST is constructed by recursively partitioning patient length of stay data into subgroups (or clusters) based on covariates maximising within-node homogeneity based on splitting criteria [53]. These covariates represent patient\" characteristics such as gender, age at admission, and disease (diagnosed) available in the dataset used and have previously been identified in the literature and anecdotally as useful [52; 54; 60; 64]. Each cluster is separately fitted to the C-PHDs [62; 63]. C-PHDs model a patient's journey through the care system as an \(n\)-state continuous time-absorbing Markov chain (Figure 1) with a single absorbing state. These partially observable states represent stages through the time spent in the hospital before discharge or death. This single absorbing state might cover both death and discharge, making the model focussed on the institution (e.g., capacity, costs) as patient-centred. Therefore, the community care-centred perspectives would consider multiple absorbing states in Section 2.3 (extended PHTST) and Section 2.4.2 (multi-absorbing state). A patient can be admitted to the hospital in the first state and then sequentially move to the next state with a transition rate \(\lambda_{i}\). (\(i=1\),\(2\),... \(n\)), constituting movement from any state \(i\) to the absorbing state (representing death or discharge from hospital) \(n+1\) with transition rate \(\mu_{i}\). The transition matrix \(\mathbf{Q}\) for the absorbing Markov chain can be defined as follows:\[\mathbf{Q}= \begin{pmatrix}-(\lambda_{1}+\mu_{1})&\lambda_{1}&0&\cdots&0&0&\mu_{1}\\ 0&-(\lambda_{2}+\mu_{2})&\lambda_{2}&\cdots&0&0&\mu_{2}\\ \vdots&\vdots&\vdots&\cdots&\vdots&\vdots&\vdots\\ 0&0&0&\cdots&-\Big{(}\lambda_{(n-1)}+\mu_{(n-1)}\Big{)}&\lambda_{n-1}&\mu_{(n- 1)}\\ 0&0&0&\cdots&0&-\mu_{n}&\mu_{n}\\ 0&0&0&\cdots&0&0&0\end{pmatrix}  \tag{1}\]  
The time spent in the hospital before discharge or death has the probability density function:  
\[f(t)=\mathbf{p}(\exp(\mathbf{Q}t))\mathbf{q} \tag{2}\]  
where the row vector \(\mathbf{p}\) of size (\(n+1\)) is:  
\[\mathbf{p}= \begin{pmatrix}1&0&0&\ldots 0&0\end{pmatrix}  \tag{3}\]  
\(\mathbf{Q}\) represents the initial patient\" distribution, and column vector \(\mathbf{q}\), representing absorption rates, is defined as follows:  
\[\mathbf{q}= \begin{pmatrix}\mu_{1}&\mu_{2}&\ldots&\mu_{n}&\mu_{n+1}\end{pmatrix} ^{T}. \tag{4}\]  
The log-likelihood function is defined as follows [63]:  
\[\text{Log likelihood}=\sum_{i=1}^{N}(\log(\mathbf{p}\exp\{\mathbf{Q}t_{i}\}\mathbf{q}))\;. \tag{5}\]  
where \(N\) is the total number of patients. **Splitting criteria**  
A partition maximising within-node homogeneity at each node is selected based on a splitting criterion. There are several splitting criteria available to use [53], such as the criteria based on the maximum likelihood ratio, the criteria based on Akaike Information Criterion [65], the criteria based on Schwartz Bayesian Information Criterion [66], the criteria based on Corrected AIC [67], the criteria based on Corrected BIC [68], and the criteria based on the weighted-average information criterion [69]. Ref. [53] critically assessed each of these splitting criteria. It found that the splitting criteria based on the Weighted-Average Information Criterion (WIC) outperforms other splitting criteria listed here with both small and large sample sizes and also in situations where the sample size is unknown [69; 70]. Therefore, we will use WIC-based splitting criteria to construct PHTST. The WIC for the fit of a node can be defined as follows [53; 69]:  
Figure 1: A patient pathway as an \(n\)-state absorbing Markov chain.