Weibull AFT Regression Functions in R
Weibull accelerated failure time regression can be performed in R using the survreg function. The results are not, however, presented in a form in which the Weibull distribution is usually given. Accelerated failure time models are usually given by
where are set of covariates, and has the extreme value distribution. Given transformations
we have a Weibull model with baseline hazard of
Further, the survreg function generally gives , rather than as output. The function WeibullReg (along with ConvertWeibull) solves this problem. Hazard ratios () are additionally produced.
The function also produces the “event time ratio” (ETR, ), as discussed in Carroll (2003). This ratio quantifies the relative difference in time it takes to achieve the th percentile between two levels of a covariate. The th percentile of the (covariate-adjusted) Weibull distribution occurs at
Then the ratio of times for a covariate with value versus values , with parameter estimate , can then be computed as:
Thus, if we are comparing treatment B to treatment A, where the parameter estimate for treatment B is , then the ETR is .
For example if the ETR for treatments A vs B is 1.2, then the amount of time it takes for percent of patients with treatment A to have the event is predicted to be about 20% longer than it takes for the same percentage of patients with treatment B to experience an event. (That is, treatment B is worse.) For this reason, the ETR can also be called an “acceleration factor.”
Additionally, a function WeibullDiag has been provided to check the adequacy of the Weibull Model.
1 WeibullReg
The WeibullReg function performs Weibull AFT regression on survival data, returning a list which contains:
- formula
-
the regression formula,
- coef
-
the coefficient table,
- HR
-
a table with the hazard rates (with confidence intervals) for each of the covariates,
- ETR
-
a table with the Event Time Ratios (with confidence intervals) for each of the covariates, and
- summary
-
the summary table from the original survreg model.
Such tables can also be produced using the streg function in stata with the following options: 1) the nohr option gives coef, 2) without any options gives HR, 3) the tr option gives ETR, and 4) the time option produces summary, the original output from survreg. While proc lifereg in SAS can also perform parametric regression for survival data, its output must also be transformed.
The following example reproduces Tables 12.1 and 12.2 from Klein and Moeschberger (2003), on the larynx data set.
> library(survival)> data(larynx)
> WeibullReg(Surv(time, death) ~ factor(stage) + age, data=larynx)
$formulaSurv(time, death) ~ factor(stage) + age$coef Estimate SElambda 0.01853664 0.01898690gamma 1.13014371 0.13844846factor(stage)2 0.16692694 0.46112943factor(stage)3 0.66289534 0.35550887factor(stage)4 1.74502788 0.41476410age 0.01973646 0.01424135$HR HR LB UBfactor(stage)2 1.181668 0.4786096 2.917491factor(stage)3 1.940402 0.9666786 3.894946factor(stage)4 5.726061 2.5398504 12.909334age 1.019933 0.9918573 1.048802$ETR ETR LB UBfactor(stage)2 0.8626863 0.3880879 1.917678factor(stage)3 0.5562383 0.2971113 1.041364factor(stage)4 0.2135090 0.1047619 0.435140age 0.9826879 0.9583820 1.007610$summaryCall:survival::survreg(formula = formula, data = data, dist = "weibull") Value Std. Error z p(Intercept) 3.5288 0.9041 3.90 9.5e-05factor(stage)2 -0.1477 0.4076 -0.36 0.717factor(stage)3 -0.5866 0.3199 -1.83 0.067factor(stage)4 -1.5441 0.3633 -4.25 2.1e-05age -0.0175 0.0128 -1.37 0.172Log(scale) -0.1223 0.1225 -1.00 0.318Scale= 0.885Weibull distributionLoglik(model)= -141.4 Loglik(intercept only)= -151.1Chisq= 19.37 on 4 degrees of freedom, p= 0.00066Number of Newton-Raphson Iterations: 5n= 90
The hazard rates produced with the Weibull regression model are similar to what is obtained with Cox proportional hazards regression:
> cph <- coxph(Surv(time, death) ~ factor(stage) + age, data=larynx)> summary(cph)$conf.int
exp(coef) exp(-coef) lower .95 upper .95factor(stage)2 1.150320 0.8693233 0.4646755 2.847656factor(stage)3 1.901003 0.5260381 0.9459343 3.820364factor(stage)4 5.506778 0.1815944 2.4085976 12.590147age 1.019213 0.9811488 0.9911247 1.048098
Most of the work of the function is actually performed by ConvertWeibull. These functions require the survival package in R. Formulas for the variance estimates come from (Klein and Moeschberger, 2003, Equations 12.2.13-18, with some modifications since R gives ).
2 WeibullDiag
The WeibullDiag function produces a diagnostic plot for Weibull AFT regression, similar to what is in (Klein and Moeschberger, 2003, Figure 12.2). It plots versus the log of the estimated cumulative hazard estimate. If the Weibull model has adequate fit, then the plots for each of the covariates should be roughly linear and parallel. This function requires the survfit object to contain strata, else an error is produced. The WeibullDiag function requires the survival package.
> WeibullDiag(Surv(time, death) ~ factor(stage), data = larynx,+ labels=c("Stage I", "Stage II", "Stage III", "Stage IV"))
References
- [1] (2003) On the use and utility of the Weibull model in the analysis of survival data. Controlled Clinical Trials 24 (6), pp. 682 – 701. Cited by: Weibull AFT Regression Functions in R.
- [2] (2003) Survival analysis: techniques for censored and truncated data. Springer Verlag. Cited by: §1, §1, §2.