Weibull Lifetime Distribution Model

The theoretical population models used to describe unit lifetimes are known as Lifetime Distribution Models. The population is generally considered to be all of the possible unit lifetimes for all of the units that could be manufactured based on a particular design and choice of materials and manufacturing process. A random sample of size n from this population is the collection of failure times observed for a randomly selected group of n units.The Weibull is a very flexible life distribution model with two parameters.

Evaluate the PDF a Weibull distribution

library(survival)
library(SurvRegCensCov)

## Evaluate the PDF a Weibull distribution with 
## T=1000, gamma=1.5, and alpha=5000.
T = 1000
gamma = 1.5 
alpha = 5000
dweibull(T, gamma, alpha)
## [1] 0.0001226851
##> [1] 0.0001226851

Evaluate the CDF a Weibull distribution

## Evaluate the CDF a Weibull distribution with T=1000, 
## gamma=1.5, and alpha=5000.
pweibull(T, gamma, alpha)
## [1] 0.08555936
##> [1] 0.08555936

Generate probability plot from a Weibull

## Generate 100 random numbers from a Weibull with shape parameter 
## gamma=1.5 and characteristic life alpha=5000.
sample = rweibull(100, 1.5, 5000)


## The Weibull probability plot is not available directly in R. However, 
## the plot can be created using the formula -ln(1 - p) for the percentiles
## and plotting on a log-log scale.

## Generate a Weibull probability plot for the data generated.
p = ppoints(sort(sample), a=0.3)
plot(sort(sample), -log(1-p), log="xy", type="o", col="blue",
     xlab="Time", ylab="ln(1/(1-F(t)))",
     main = "Weibull Q-Q Plot")

The hazard rates

The hazard rates produced with the Weibull regression model are similar to what is obtained with Cox proportional hazards regression:

data(larynx)
WeibullReg(Surv(time, death) ~ factor(stage) + age, data=larynx)
## $formula
## Surv(time, death) ~ factor(stage) + age
## 
## $coef
##                  Estimate         SE
## lambda         0.01853664 0.01898690
## gamma          1.13014371 0.13844846
## factor(stage)2 0.16692694 0.46112943
## factor(stage)3 0.66289534 0.35550887
## factor(stage)4 1.74502788 0.41476410
## age            0.01973646 0.01424135
## 
## $HR
##                      HR        LB        UB
## factor(stage)2 1.181668 0.4786096  2.917491
## factor(stage)3 1.940402 0.9666786  3.894946
## factor(stage)4 5.726061 2.5398504 12.909334
## age            1.019933 0.9918573  1.048802
## 
## $ETR
##                      ETR        LB       UB
## factor(stage)2 0.8626863 0.3880879 1.917678
## factor(stage)3 0.5562383 0.2971113 1.041364
## factor(stage)4 0.2135090 0.1047619 0.435140
## age            0.9826879 0.9583820 1.007610
## 
## $summary
## 
## Call:
## survival::survreg(formula = formula, data = data, dist = "weibull")
##                  Value Std. Error      z        p
## (Intercept)     3.5288     0.9041  3.903 9.50e-05
## factor(stage)2 -0.1477     0.4076 -0.362 7.17e-01
## factor(stage)3 -0.5866     0.3199 -1.833 6.68e-02
## factor(stage)4 -1.5441     0.3633 -4.251 2.13e-05
## age            -0.0175     0.0128 -1.367 1.72e-01
## Log(scale)     -0.1223     0.1225 -0.999 3.18e-01
## 
## Scale= 0.885 
## 
## Weibull distribution
## Loglik(model)= -141.4   Loglik(intercept only)= -151.1
##  Chisq= 19.37 on 4 degrees of freedom, p= 0.00066 
## Number of Newton-Raphson Iterations: 5 
## n= 90
cph <- coxph(Surv(time, death) ~ factor(stage) + age, data=larynx)
summary(cph)$conf.int
##                exp(coef) exp(-coef) lower .95 upper .95
## factor(stage)2  1.150320  0.8693233 0.4646755  2.847656
## factor(stage)3  1.901003  0.5260381 0.9459343  3.820364
## factor(stage)4  5.506778  0.1815944 2.4085976 12.590147
## age             1.019213  0.9811488 0.9911247  1.048098

The Weibull Diagnostic Plot

The WeibullDiag function produces a diagnostic plot for Weibull AFT regression, similar to KM. It plots log Time 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.

WeibullDiag(Surv(time, death) ~ factor(stage), data = larynx,labels=c("Stage I", "Stage II", "Stage III", "Stage IV"))