class: center, middle, inverse, title-slide # Piece-wise exponential (Additive Mixed) Modeling Tools ## ISCB41, 2020
###
Andreas Bender (
@adibender
)
,
Fabian Scheipl, David Rügamer, Philipp Kopper, Bernd Bischl, Helmut Küchenhoff ###
Department of Statistics, LMU Munich --- layout: true <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <div class="my-footer"><span><i class="fa fa-twitter">@adibender</i>                            </span></div> ??? `$$\usepackage{amsmath,amssymb,bm} \newcommand{\ra}{\rightarrow} \newcommand{\bs}[1]{\boldsymbol{#1}} \newcommand{\tn}[1]{\textnormal{#1}} \newcommand{\mbf}[1]{\mathbf{#1}} \newcommand{\E}{\mathbb{E}} \newcommand{\bfx}{\mathbf{x}} \newcommand{\bfX}{\mathbf{X}} \newcommand{\bfB}{\mathbf{B}} \newcommand{\bff}{\mathbf{f}} \newcommand{\bsbeta}{\boldsymbol{\beta}}$$` --- ### The framework is *general* in the sense that <br><br> .font120[ 1. it supports different Survival Tasks - right-censoring, left-truncation - time-varying effects, time-varying features - cumulative effects (weighted cumulative exposure, distributed lag models) - competing risks, multi-state models 2. does not require specialized Software, can be applied - across programming languages and - using any algorithm that supports optimization of the Poisson Likelihood ] --- .center[ <img src="img/pem-framework.svg", width = "800px"> ] (source: [Bender, et al. (2020)](https://arxiv.org/abs/2006.15442)) --- layout:false class: inverse, middle, center .font200[Survival Analysis as Poisson Regression] <html> <div style='float:left'></div> <hr color='#005500' size=1px width=1000px> </html> --- layout: true layout: true <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <div class="my-footer"><span><i class="fa fa-twitter">@adibender</i>                            </span></div> --- Consider setting with right-censored data: - we observe `\((t_i, \delta_i), i = 1,\ldots, n\)`, where - `\(t_i = \min(T_i, C_i)\)`; `\(T_i \sim F \perp C_i \sim G; T_i,C_i > 0\)` - `\(\delta_i = I(T_i \leq C_i) \in \{0,1\}\)` To approximate `$$\lambda(t; \bfx_i) = \exp(g(\bfx_i(t), t)) \stackrel{PH}{=}\lambda_0(t)\exp(\bfx_i'\bsbeta)$$` -- - split the follow-up in `\(J\)` intervals `\((\kappa_{j-1}, \kappa_j], j = 1,\ldots, J\)` -- - assume piece-wise constant hazards: `$$\begin{align} \lambda(t| \bfx_i(t)) & \equiv \exp(g(\bfx_{ij}, t_j)):=\lambda_{ij},\ \ \forall t \in (\kappa_{j-1}, \kappa_j],\\ \end{align}$$` -- - Estimation using - Piece-wise Exponential Model (PEM; e.g.: [Laird, et al. (1981)](http://www.jstor.org/stable/2287816); [Friedman (1982)](http://www.jstor.org/stable/2240502); [Carstensen, et al. (2011)](https://www.jstatsoft.org/index.php/jss/article/view/v038i06)) - Piece-wise exponential Additive Mixed Models (PAMM, e.g.: [Cai, et al. (2002)](http://dx.doi.org/10.1198/106186002862); [Kauermann (2005)](http://www.sciencedirect.com/science/article/pii/S0167947304001240); [Argyropoulos, et al. (2015)](http://dx.doi.org/10.1371/journal.pone.0123784); [Bender, et al. (2018)](https://doi.org/10.1177/1471082X17748083)) --- <div class="row"> <div class = "column", align = "center"> Data in "standard" time-to-event format <br> </div> <div class = "column", align = "center"> Data in PED format <br> </div> </div> <div class = "row" align = "middle"> <div class = "column", align = "middle"> .middle[ <img src="img/tab-standard.svg", width = "300px" align="middle"><br> `\(\ra\)` transform to PED using `\(\kappa_0=0, \kappa_1 = 1, \kappa_2=1.5, \kappa_3=3\)` ] </div> <div class = "column" align ="middle"> <img src="img/tab-ped.svg", width = "400px" align="middle" > </div> </div> --- count: false <div class="row"> <div class = "column", align = "center"> Data in "standard" time-to-event format <br> </div> <div class = "column", align = "center"> Data in PED format <br> </div> </div> <div class = "row" align = "middle"> <div class = "column", align = "middle"> .middle[ <img src="img/tab-standard.svg", width = "300px" align="middle"><br> `\(\ra\)` transform to PED using `\(\kappa_0=0, \kappa_1 = 1, \kappa_2=1.5, \kappa_3=3\)` ] </div> <div class = "column" align ="middle"> <img src="img/tab-ped1.svg", width = "400px" align="middle" > </div> </div> --- count: false <div class="row"> <div class = "column", align = "center"> Data in "standard" time-to-event format <br> </div> <div class = "column", align = "center"> Data in PED format <br> </div> </div> <div class = "row" align = "middle"> <div class = "column", align = "middle"> .middle[ <img src="img/tab-standard.svg", width = "300px" align="middle"><br> `\(\ra\)` transform to PED using `\(\kappa_0=0, \kappa_1 = 1, \kappa_2=1.5, \kappa_3=3\)` ] </div> <div class = "column" align ="middle"> <img src="img/tab-ped2.svg", width = "400px" align="middle" > </div> </div> - define: `\(\delta_{ij} = \begin{cases}1 & t_i \in (\kappa_{j-1}, \kappa_j] \wedge \delta_i = 1\\0 & \text{else}\end{cases}\)` --- count: false <div class="row"> <div class = "column", align = "center"> Data in "standard" time-to-event format <br> </div> <div class = "column", align = "center"> Data in PED format <br> </div> </div> <div class = "row" align = "middle"> <div class = "column", align = "middle"> .middle[ <img src="img/tab-standard.svg", width = "300px" align="middle"><br> `\(\ra\)` transform to PED using `\(\kappa_0=0, \kappa_1 = 1, \kappa_2=1.5, \kappa_3=3\)` ] </div> <div class = "column" align ="middle"> <img src="img/tab-ped3.svg", width = "400px" align="middle" > </div> </div> - define: `\(\delta_{ij} = \begin{cases}1 & t_i \in (\kappa_{j-1}, \kappa_j] \wedge \delta_i = 1\\0 & \text{else}\end{cases}\)`, `\(t_{ij} = \begin{cases}t_{i}-\kappa_{j-1} & \delta_{ij}=1\\ \kappa_{j}-\kappa_{j-1}& \text{else}\end{cases}\)` --- count: false <div class="row"> <div class = "column", align = "center"> Data in "standard" time-to-event format <br> </div> <div class = "column", align = "center"> Data in PED format <br> </div> </div> <div class = "row" align = "middle"> <div class = "column", align = "middle"> .middle[ <img src="img/tab-standard.svg", width = "300px" align="middle"><br> `\(\ra\)` transform to PED using `\(\kappa_0=0, \kappa_1 = 1, \kappa_2=1.5, \kappa_3=3\)` ] </div> <div class = "column" align ="middle"> <img src="img/tab-ped4.svg", width = "400px" align="middle" > </div> </div> - define: `\(\delta_{ij} = \begin{cases}1 & t_i \in (\kappa_{j-1}, \kappa_j] \wedge \delta_i = 1\\0 & \text{else}\end{cases}\)`, `\(t_{ij} = \begin{cases}t_{i}-\kappa_{j-1} & \delta_{ij}=1\\ \kappa_{j}-\kappa_{j-1}& \text{else}\end{cases}\)`, `\(t_j := \kappa_j\)` --- count: false <div class="row"> <div class = "column", align = "center"> Data in "standard" time-to-event format <br> </div> <div class = "column", align = "center"> Data in PED format <br> </div> </div> <div class = "row" align = "middle"> <div class = "column", align = "middle"> .middle[ <img src="img/tab-standard.svg", width = "200px" align="middle"><br> `\(\ra\)` transform to PED using `\(\kappa_0=0, \kappa_1 = 1, \kappa_2=1.5, \kappa_3=3\)` ] </div> <div class = "column" align ="middle"> <img src="img/tab-ped.svg", width = "300px" align="middle" > </div> </div> - define: `\(\delta_{ij} = \begin{cases}1 & t_i \in (\kappa_{j-1}, \kappa_j] \wedge \delta_i = 1\\0 & \text{else}\end{cases}\)`, `\(t_{ij} = \begin{cases}t_{i}-\kappa_{j-1} & \delta_{ij}=1\\ \kappa_{j}-\kappa_{j-1}& \text{else}\end{cases}\)`, `\(t_j := \kappa_j\)` .font80[ .pull-left[ .boxed_grey[ General log-likelihood contribution: `$$\begin{align}\ell_i & = \log(\lambda(t_i;\bfx_i)^{\delta_i}S(t_i;\bfx_i))\\ % & = \delta_i\log(\lambda_{iJ_i}) - \sum_{j=1}^{J_i}\lambda_{ij}t_{ij}\\ & = \sum_{j=1}^{J_i}\left(\delta_{ij}\log\lambda_{ij} - \lambda_{ij}t_{ij}\right) \end{align}$$` ] ] .pull-right[ .boxed_grey[ Working Assumption `\(\delta_{ij}\stackrel{iid}{\sim} Po(\mu_{ij} = \lambda_{ij}t_{ij})\)`: `$$\begin{align} \ell_i & = \log\left(\prod_{j=1}^{J_i} f(\delta_{ij})\right)\\ % & = \sum_{j=1}^{J_i} \delta_{ij}\log(\mu_{ij}) - \mu_{ij}\nn\\ & = \sum_{j=1}^{J_i} \delta_{ij}\log(\lambda_{ij}) + \delta_{ij}\log(t_{ij}) - \lambda_{ij}t_{ij} \end{align}$$` ] ] ] --- **Competing risks** setting with event types `\(k \in \{1,2\}\)` <div class="row"> <div class = "column", align = "center"> Data in "standard" format <br> </div> <div class = "column", align = "center"> Data in PED format <br> </div> </div> <div class = "row" align = "middle"> <div class = "column", align = "middle"> .middle[ <img src="img/tab-standard-cr.svg", width = "300px" align="middle"><br> `\(\ra\)` transform to PED using `\(\kappa_0=0, \kappa_1 = 1, \kappa_2=1.5, \kappa_3=3\)` ] </div> <div class = "column" align ="middle"> <img src="img/tab-cr1.svg", width = "400px" align="middle" > </div> </div> `\(\ra\)` estimate `\(\lambda(t|\bfx, k) = \exp(f(\bfx(t),t,k)),\ k \in \{1,2\}\)` --- count: false **Competing risks** setting with event types `\(k \in \{1,2\}\)` <div class="row"> <div class = "column", align = "center"> Data in "standard" format <br> </div> <div class = "column", align = "center"> Data in PED format <br> </div> </div> <div class = "row" align = "middle"> <div class = "column", align = "middle"> .middle[ <img src="img/tab-standard-cr.svg", width = "300px" align="middle"><br> `\(\ra\)` transform to PED using `\(\kappa_0=0, \kappa_1 = 1, \kappa_2=1.5, \kappa_3=3\)` ] </div> <div class = "column" align ="middle"> <img src="img/tab-cr2.svg", width = "400px" align="middle" > </div> </div> `\(\ra\)` estimate `\(\lambda(t|\bfx, k) = \exp(f(\bfx(t_j),t_j,k)),\ \forall t\in(\kappa_{j-1}, \kappa_j],\ \ k \in \{1,2\}\)` --- **PEM/GLM**: `\(\lambda(t) = \lambda_{0j} = \exp(\beta_{0j}), \forall t\in (\kappa_{j-1}, \kappa_j], j = 1,\ldots,J\)` <img src="iscb2020-extended-pamm_files/figure-html/unnamed-chunk-3-1.png" width="600px" style="display: block; margin: auto;" /> - trade of w.r.t. to number of split points (less flexible/more robust vs. more flexible/less robust) - computationally inefficient (one parameter for each interval), especially when considering time-varying effects - results sensitive to number and placement of interval cut points --- **PAMM/GAMM**: `\(\lambda(t) = \lambda_{0j} = \exp(f_0(t_j)), \forall t\in (\kappa_{j-1}, \kappa_j], j = 1,\ldots,J;\ f_0(t_j) = \sum_{q=1}^{Q}\beta_{0q}B_{0q}(t_j)\)` <img src="iscb2020-extended-pamm_files/figure-html/unnamed-chunk-4-1.png" width="300px" style="display: block; margin: auto;" /> - large differences between neighboring coefficients/baseline hazards of neighboring intervals are penalized - insensitive to number and placement of split points - number of parameters to estimate determined by basis dimension `\(Q\)`, not number of intervals `\(J\)` --- ## Time-varying effects In the PEM/PAMM framework, time-varying effects are simply interactions of time `\(t_j\)` and other covariates. <br> `$$\log(\lambda(t|x)) = f_{01}(t_j)I(complications = yes) + f_{02}(t_j)I(complications = no)$$` ```r pam_tumor <- mgcv::gam(formula=ped_status~s(tend, by=complications), data=ped_tumor, family=poisson(), offset=offset) ``` <img src="iscb2020-extended-pamm_files/figure-html/unnamed-chunk-7-1.png" width="800px" style="display: block; margin: auto;" /> --- ```r # "Regular" GAM mgcv::gam(formula=ped_status~s(tend, by=complications), data=ped_tumor, family=poisson(), offset=offset) # GAM with monotinicity constraints scam::scam(formula=ped_status~s(tend, by=complications, bs = "mpd"), data=ped_tumor, family=poisson(), offset=offset) # Bayesian GAM brms::brm(formula=ped_status~s(tend, by=complications) + offset(offset), data=ped_tumor, family=poisson()) ``` --- ## Competing Risks `$$\log(\lambda(t|x)) = f_{01}(t_j)I(k = 1) + f_{01}(t_j)I(k = 2)$$` Cause specific hazards are time-varying effects of time `\(t_j\)` and covariate "event type" `\(k\)` ```r pam_cr <- mgcv::gam(formula = ped_status ~ s(tend, by = cause), data = ped_stacked, family = poisson(), offset = offset) ``` <img src="iscb2020-extended-pamm_files/figure-html/unnamed-chunk-10-1.png" width="400px" style="display: block; margin: auto;" /> --- ## Tree based methods .column[Time-varying effects] .column[Shared vs. cause-specific effects (in CR)] .center[ <img src="img/splits-grey.svg", width = "800px"> ] (source: [Bender, et al. (2020)](https://arxiv.org/abs/2006.15442)) --- layout:false class: inverse, middle, center .font200[The **`pammtools`** package] <html> <div style='float:left'></div> <hr color='#005500' size=1px width=1000px> </html> --- layout: true <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/github.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <div class="my-footer"><span><i class="fa fa-twitter">@adibender</i>                            </span></div> --- .font120[ PEMs/PAMMs powerfull framework for survival analysis, but cumbersome to work with **`pammtools`** facilitates - data transformation (`as_ped`): + right-censoring + cumulative effects + competing risks - post-processing: + prediction (`add_hazard`, `add_surv_prob`, `add_cif`), + model evaluation (integrated brier score via **`pec`**) - convenience functions for visualisation, ... ] --- background-image: url(img/screenshot-hp.png) background-size: contain https://adibender.github.io/pammtools/index.html --- ## Outlook <br><br><br> - support for multi-state models - facilitate extensions: S3 functions for calculation of hazard for other packages (e.g. **`mbooost`**, **`brms`**) - Prototype for PEMs using **`xgboost`** available: https://github.com/adibender/pem.xgb - However, ML algorithms need a different infrastructure (resampling, tuning, benchmarking) <br> `\(\ra\)` Development will probably continue in **`mlr3`** and **`mlr3proba`** ([Lang, et al. (2019)](https://joss.theoj.org/papers/10.21105/joss.01903); [Sonabend, et al. (2020)](http://arxiv.org/abs/2008.08080)) --- layout: false ## References <a name=bib-argyropoulos_analysis_2015></a>[Argyropoulos, C. et al.](#cite-argyropoulos_analysis_2015) (2015). "Analysis of Time to Event Outcomes in Randomized Controlled Trials by Generalized Additive Models". In: _PLoS ONE_ 10.4, p. e0123784. DOI: [10.1371/journal.pone.0123784](https://doi.org/10.1371%2Fjournal.pone.0123784). URL: [http://dx.doi.org/10.1371/journal.pone.0123784](http://dx.doi.org/10.1371/journal.pone.0123784). <a name=bib-bender_generalized_2018></a>[Bender, A. et al.](#cite-bender_generalized_2018) (2018). "A generalized additive model approach to time-to-event analysis". En. In: _Statistical Modelling_ 18.3-4, pp. 299-321. ISSN: 1471-082X. DOI: [10.1177/1471082X17748083](https://doi.org/10.1177%2F1471082X17748083). <a name=bib-bender_general_2020></a>[Bender, A. et al.](#cite-bender_general_2020) (2020). "A General Machine Learning Framework for Survival Analysis". In: _arXiv:2006.15442 [cs, stat]_. arXiv: [2006.15442](https://arxiv.org/abs/2006.15442). <a name=bib-cai_mixed_2002></a>[Cai, T. et al.](#cite-cai_mixed_2002) (2002). "Mixed Model-Based Hazard Estimation". In: _Journal of Computational and Graphical Statistics_ 11.4, pp. 784-798. ISSN: 1061-8600. DOI: [10.1198/106186002862](https://doi.org/10.1198%2F106186002862). URL: [http://dx.doi.org/10.1198/106186002862](http://dx.doi.org/10.1198/106186002862). <a name=bib-carstensen_using_2011></a>[Carstensen, B. et al.](#cite-carstensen_using_2011) (2011). "Using Lexis Objects for Multi-State Models in R". En. In: _Journal of Statistical Software_ 38.1. Number: 1, pp. 1-18. ISSN: 1548-7660. DOI: [10.18637/jss.v038.i06](https://doi.org/10.18637%2Fjss.v038.i06). URL: [https://www.jstatsoft.org/index.php/jss/article/view/v038i06](https://www.jstatsoft.org/index.php/jss/article/view/v038i06). <a name=bib-friedman_piecewise_1982></a>[Friedman, M.](#cite-friedman_piecewise_1982) (1982). "Piecewise Exponential Models for Survival Data with Covariates". In: _The Annals of Statistics_ 10.1, pp. 101-113. ISSN: 00905364. URL: [http://www.jstor.org/stable/2240502](http://www.jstor.org/stable/2240502). --- layout: false ## References <a name=bib-kauermann_penalized_2005></a>[Kauermann, G.](#cite-kauermann_penalized_2005) (2005). "Penalized spline smoothing in multivariable survival models with varying coefficients". In: _Computational Statistics & Data Analysis_ 49.1, pp. 169-186. ISSN: 0167-9473. DOI: [10.1016/j.csda.2004.05.006](https://doi.org/10.1016%2Fj.csda.2004.05.006). URL: [http://www.sciencedirect.com/science/article/pii/S0167947304001240](http://www.sciencedirect.com/science/article/pii/S0167947304001240). <a name=bib-laird_covariance_1981></a>[Laird, N. et al.](#cite-laird_covariance_1981) (1981). "Covariance Analysis of Censored Survival Data Using Log-Linear Analysis Techniques". In: _Journal of the American Statistical Association_ 76.374, pp. 231-240. DOI: [10.2307/2287816](https://doi.org/10.2307%2F2287816). URL: [http://www.jstor.org/stable/2287816](http://www.jstor.org/stable/2287816). <a name=bib-mlr3></a>[Lang, M. et al.](#cite-mlr3) (2019). "mlr3: A modern object-oriented machine learning framework in R". In: _Journal of Open Source Software_. DOI: [10.21105/joss.01903](https://doi.org/10.21105%2Fjoss.01903). URL: [https://joss.theoj.org/papers/10.21105/joss.01903](https://joss.theoj.org/papers/10.21105/joss.01903). <a name=bib-sonabend_mlr3proba_2020></a>[Sonabend, R. et al.](#cite-sonabend_mlr3proba_2020) (2020). "mlr3proba: Machine Learning Survival Analysis in R". In: _arXiv:2008.08080 [cs, stat]_. arXiv: 2008.08080. URL: [http://arxiv.org/abs/2008.08080](http://arxiv.org/abs/2008.08080) (visited on Aug. 20, 2020).