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.
Installation
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:
Let $(t_{i}, \delta_{i})$ be the observed survival time and its
corresponding failure indicator, $i=1, \cdots, n$, and
$\boldsymbol{\theta}$ be a $k \times 1$ vector of parameters. Then, the
likelihood function for right-censored survival data under independent
censoring can be expressed as:
The maximum likelihood estimate (MLE) of $\boldsymbol{\theta}$ is
obtained by directly maximization of $\log(L(\boldsymbol{\theta}))$
using the rstan::optimizing() function. The function
rstan::optimizing() further provides the hessian matrix of
$\log(L(\boldsymbol{\theta}))$, needed to obtain the observed Fisher
information matrix, which is given by:
$$
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 $\alpha>0$ and $\gamma>0$ are the shape and scale parameters,
respectively.
The survival and hazard functions in this case are given by:
$$
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 $-\infty < \mu < \infty$ and $\sigma>0$ are the mean and
standard deviation in the log scale of $T$.
The survival and hazard functions in this case are given by:
$$S(t|\mu, \sigma) = \Phi\left(\frac{-log(t)+\mu}{\sigma}\right)$$ and
$$h(t|\mu, \sigma) = \frac{f(t|\mu, \sigma)}{S(t|\mu, \sigma)},$$ where
$\Phi(\cdot)$ is the cumulative distribution function of the standard
normal distribution.
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 $\mathbf{x}$ be a $1\times p$ vector of covariates,
$\boldsymbol{\beta}$ a $p \times 1$ of regression coefficients, and
$\boldsymbol{\theta}$ a vector of parameters associated with some
baseline survival distribution, and denote by
$\boldsymbol{\Theta} = (\boldsymbol{\theta}, \boldsymbol{\beta})^{T}$
the full vector of parameters. Here, to ensure identifiability, in all
regression structures the linear predictor
$\mathbf{x} \boldsymbol{\beta}$ does not include a intercept term.
The regression survival models implemented in the R package survstan are
briefly described in the sequel.
Accelerate Failure Time Models
Accelerated failure time (AFT) models are defined as
$$
T = \exp{\mathbf{x} \boldsymbol{\beta}}\nu,
$$ where $\nu$ follows a baseline distribution with survival function
$S_{0}(\cdot|\boldsymbol{\theta})$ so that
$$
f(t|\boldsymbol{\Theta}, \mathbf{x}) = e^{-\mathbf{x} \boldsymbol{\beta}}f_{0}(te^{-\mathbf{x} \boldsymbol{\beta}}|\boldsymbol{\theta})
$$ and
$$
h(t|\Theta, \mathbf{x}) = h_{0}(t|\boldsymbol{\theta})\exp{\mathbf{x} \boldsymbol{\beta}},
$$ where $h_{0}(t|\boldsymbol{\theta})$ is a baseline hazard function so
that
$$
R(t|\Theta, \mathbf{x}) = R_{0}(t|\boldsymbol{\theta})\exp{\mathbf{x} \boldsymbol{\beta}},
$$ where
$\displaystyle R_{0}(t|\boldsymbol{\theta}) = \frac{1-S_{0}(t|\boldsymbol{\theta})}{S_{0}(t|\boldsymbol{\theta})} = \exp{H_{0}(t|\boldsymbol{\theta})}-1$
is a baseline odds function so that