R code for Martingale residuals of a parametric survival model

Martingale residuals are helpful for detecting the correct functional form of a continuous predictor in a survival model. A mathematical definition of Martingale like residuals for the Accelerated Failure Time model (which is a parametric survival model) can be found in Collett’s 2003 book Modelling survival data in medical research. The R code implements Collett’s approach to Martingale residuals for the AFT model.

AFT model Martingale residuals

Continue reading R code for Martingale residuals of a parametric survival model

R code for constructing likelihood based confidence intervals for the hazard function

The following R code may be used for computing likelihood based confidence intervals for the hazard function of an Accelerated Failure Time model. The code computes the likelihood based confidence intervals for failure times that follow either a Weibull or lognormal distribution.

Definition of the hazard function
The hazard function (or hazard rate) at time t is given by:

h(t)=\frac{f(t)}{S(t)}

where f(·) is the probability density function of the failure times, and S(·) the survival function. Continue reading R code for constructing likelihood based confidence intervals for the hazard function

R code for constructing bootstrap confidence intervals for the hazard function

The following R code may be used for computing the hazard function (also known as the hazard rate) of the Accelerated Failure Time model. The code computes the hazard function for failure times that follow either a Weibull or lognormal distribution.

The code also computes normal-approximation and bootstrap confidence intervals for the hazard function. For calculating the latter confidence intervals the code employs the nonparametric bootstrap-t method.

AFT model hazard function bootstrap ci

Continue reading R code for constructing bootstrap confidence intervals for the hazard function

R code for constructing likelihood based confidence intervals for the regression coefficients of an Accelerated Failure Time model

The following R code computes likelihood based confidence intervals for the regression coefficients of an Accelerated Failure Time model. The AFT model is a parametric survival model.

AFT model coefficients

Continue reading R code for constructing likelihood based confidence intervals for the regression coefficients of an Accelerated Failure Time model

R code for constructing likelihood based confidence intervals for the cumulative probabilities and quantiles of an Accelerated Failure Time model

Failure times may be modeled as a function of explanatory variables. The Accelerated Failure Time model (AFT model) is often used for finding the relationship between failure times and explanatory variables.
In a reliability engineering context, for instance, an Accelerated Life Test is often used for determining the effect of variables (such as temperature or voltage) on the durability of some component. For relating the variables to the durability of the component, the reliability engineer usually employs an AFT model.
The following R code computes the likelihood based confidence intervals at specific values of the explanatory variables for 1) the cumulative probabilities, and 2) the quantiles. Note that a reliability engineer may refer to the cumulative probabilities as failure probabilities, and to the quantiles as life time quantiles.

AFT model quantiles and cumulative probabilities

Continue reading R code for constructing likelihood based confidence intervals for the cumulative probabilities and quantiles of an Accelerated Failure Time model