toolkit for fitting survival models using Stan.
The R package survstan can be used to fit right-censored survival data under independent censoring. The implemented models allow the fitting of survival data in the presence/absence of covariates. All inferential procedures are currently based on the maximum likelihood (ML) approach.
You can install the released version of survstan from CRAN with:
install.packages("survstan")
You can install the development version of survstan from GitHub with:
# install.packages("devtools")
devtools::install_github("fndemarqui/survstan")
Let
The maximum likelihood estimate (MLE) of rstan::optimizing()
function. The function
rstan::optimizing()
further provides the hessian matrix of
Inferences on
Some of the most popular baseline survival distributions are implemented in the R package survstan. Such distributions include:
- Exponential
- Weibull
- Lognormal
- Loglogistic
The parametrizations adopted in the package survstan are presented next.
If
$$
f(t|\lambda) = \lambda\exp\left{-\lambda t\right}I_{[0, \infty)}(t),
$$ where
The survival and hazard functions in this case are given by:
If
$$
f(t|\alpha, \gamma) = \frac{\alpha}{\gamma^{\alpha}}t^{\alpha-1}\exp\left{-\left(\frac{t}{\gamma}\right)^{\alpha}\right}I_{[0, \infty)}(t),
$$ where
The survival and hazard functions in this case are given by:
If
$$
f(t|\mu, \sigma) = \frac{1}{\sqrt{2\pi}t\sigma}\exp\left{-\frac{1}{2}\left(\frac{log(t)-\mu}{\sigma}\right)^2\right}I_{[0, \infty)}(t),
$$ where
The survival and hazard functions in this case are given by:
If
where
The survival and hazard functions in this case are given by:
When covariates are available, it is possible to fit four different regression models with the R package survstan:
- accelerated failure time (AFT) models;
- proportional hazards (PH) models;
- proportional odds (PO) models;
- accelerated hazard (AH) models.
- Yang and Prentice (YP) models.
Let
The regression survival models implemented in the R package survstan are briefly described in the sequel.
Accelerated failure time (AFT) models are defined as
$$
T = \exp{\mathbf{x} \boldsymbol{\beta}}\nu,
$$ where
$$ f(t|\boldsymbol{\Theta}, \mathbf{x}) = e^{-\mathbf{x} \boldsymbol{\beta}}f_{0}(te^{-\mathbf{x} \boldsymbol{\beta}}|\boldsymbol{\theta}) $$ and
Proportional hazards (PH) models are defined as
$$
h(t|\Theta, \mathbf{x}) = h_{0}(t|\boldsymbol{\theta})\exp{\mathbf{x} \boldsymbol{\beta}},
$$ where
$$ f(t|\boldsymbol{\Theta}, \mathbf{x}) = h_{0}(t|\boldsymbol{\theta})\exp\left{\mathbf{x} \boldsymbol{\beta} - H_{0}(t|\boldsymbol{\theta})e^{\mathbf{x} \boldsymbol{\beta}}\right}, $$ and
Proportional Odds (PO) models are defined as
$$
R(t|\Theta, \mathbf{x}) = R_{0}(t|\boldsymbol{\theta})\exp{\mathbf{x} \boldsymbol{\beta}},
$$ where
and
Accelerated hazard (AH) models are defined as
so that
The survival function of the Yang and Prentice (YP) model is given by:
The hazard and the probability density functions are then expressed as:
respectively, where