Piecewise Constant Hazards Calculations
Daniel Sabanés Bové
Source:vignettes/pwc_survival.Rmd
pwc_survival.Rmd
Introduction
In this vignette we derive the explicit formula for the overall
survival under piecewise constant hazards. This is implemented in the
function PWCsurvOS()
.
So we are in the situation where the hazards for the transitions are piecewise constant, i.e. all three hazard functions (stable to progression), (stable to death) and (progression to death) are step functions. Say the start points of the constant hazard pieces for are , , with corresponding constant positive hazards . Obviously we use here the smallest set of pieces, i.e. neighboring hazards are required to be different, . This holds analogously for the hazard functions of the other two state transitions.
We denote the cumulative hazards similarly as , and . Note that these are piecewise linear, with the slope changes occurring at the times of hazard changes.
Overall survival calculation
Now we want to calculate the overall survival (OS) survival function induced by the piecewise constant hazard model. We start from
where is the survival function for OS, and is the survival function for PFS with the closed form
Hence we can rewrite the integral from above as
So overall we now have
$$ S_{\text{OS}}(t) = S_{\text{PFS}}(t) + \exp(- \Lambda_{12}(t)) \cal{I}(t) $$ and we can rewrite the integral $$ \cal{I}(t) := \int_0^t \exp(\Lambda_{12}(u) - \Lambda_{01}(u) - \Lambda_{02}(u))\lambda_{01}(u)\, du $$ in terms of the unique starting time points , chosen such that the set is the smallest super set of all state specific transition starting points , and , as
$$\begin{align} \cal{I}(t) = &\int_{t_{(1)}}^{t_{(2)}} \exp(a_{(1)} + b_{(1)}(u - t_{(1)}))h_{01(1)}\,du \\ &+ \dotsb + \\ &\int_{t_{(l)}}^{t} \exp(a_{(l)} + b_{(l)}(u - t_{(l)}))h_{01(l)}\,du, \end{align}$$ where:
- is the start of the last integral part and defined as the maximum starting point that is smaller than
- , are the hazard values for the stable to progression transition within the unique time intervals
- , are the intercepts
- , are the slopes, again using the hazard values within the unique time intervals for the specific transitions
Note that this is essentially just because of when there is a constant hazard and two time points .
We can then easily derive a closed form for each integral part, , where is the end point of the last integral:
$$\begin{align} \cal{I}_{j} &= \int_{t_{(j)}}^{t_{(j+1)}} \exp(a_{(j)} + b_{(j)}(u - t_{(j)}))h_{01(j)}\,du\\ &= \exp(a_{(j)} - b_{(j)}t_{(j)})h_{01(j)} \int_{t_{(j)}}^{t_{(j+1)}} \exp(b_{(j)}u)\,du\\ &= \exp(a_{(j)} - b_{(j)}t_{(j)})h_{01(j)} \left[ b_{(j)}^{-1}\exp(b_{(j)}u) \right]_{t_{(j)}}^{t_{(j+1)}}\\ &= \frac{h_{01(j)}}{b_{(j)}} \exp(a_{(j)} - b_{(j)}t_{(j)}) (\exp(b_{(j)}t_{(j+1)}) - \exp(b_{(j)}t_{(j)}))\\ &= \frac{h_{01(j)}}{b_{(j)}} \exp(a_{(j)}) (\exp(b_{(j)}(t_{(j+1)} - t_{(j)})) - 1) \end{align}$$
Note that if it should happen that , the integral simplifies further to $$ \cal{I}_{j} = \int_{t_{(j)}}^{t_{(j+1)}} \exp(a_{(j)})h_{01(j)}\,du = \exp(a_{(j)})h_{01(j)}(t_{(j+1)} - t_{(j)}). $$
Implementation
The above formula is implemented in the function
PWCsurvOS()
. Note that there are a few modifications
compared to above exposition:
- In order to be efficient, we look at a vector of time points directly from the beginning. Then, find the unique time points and order them, and perform piecewise integration between the sorted unique time points.
- In order to avoid numerical overflow with large time points, we move the term inside the integral, similarly as in the starting point of the derivation.