# Using the Weibull Accelerated Failure Time Regression Model to Predict Time to Health Events
## 4 Weibull AFT Regression Model  
In the Weibull AFT regression model, let \(T\) represent survival time. Consider a random sample of size n from a target population. For each subject \(i(i=1,2,\ldots,n)\), we have observed values of covariates \(x_{i1},x_{i2},\ldots,x_{ip}\) and possibly censored survival time \(t_{i}\). The Weibull AFT model can be expressed as:  
\[\log(t_{i})=\beta_{0}+\beta_{1}x_{i1}+\ldots+\beta_{p}x_{ip}+\sigma\epsilon_{ i}=\mathbf{x}_{i}^{\prime}\mathbf{\beta}+\sigma\epsilon_{i},\hskip 28.452756 pti=1,2, \ldots,n \tag{8}\]  
Here, \(\mathbf{\beta}=(\beta_{0},\ldots,\beta_{p})\) represent the regression coefficients of interest, \(\sigma\) is a scale parameter, and \(e_{1},\ldots e_{n}\) are i.i.d distributed according to a Gumbel distribution with the PDF  
\[f_{e}(x)=\exp(x)\exp[-\exp(x)] \tag{9}\]  
and the CDF  
\[F_{e}(x)=1-\exp[-\exp(x)] \tag{10}\]It is important to note that this Gumbel distribution corresponds to a \(G(0,1)\) distribution or a standard Gumbel distribution. Now, we can derive the PDF of \(T\) from Equation (8)  
\[\log(T)=\mathbf{x^{\prime}}\mathbf{\beta}+\sigma\epsilon\] \[\Rightarrow T=e^{\mathbf{x^{\prime}}\mathbf{\beta}+\sigma\epsilon}\] \[\Rightarrow\epsilon=g^{-1}(T)=\frac{\log(T)-\mathbf{x^{\prime}}\mathbf{ \beta}}{\sigma} \tag{11}\] \[\Rightarrow|J|=|\frac{d(g^{-1}(T))}{dT}|=\frac{1}{\sigma T} \tag{12}\]  
Substituting Equations (11) and (12) into Equation (9), we obtain:  
\[f_{T}(t) =f_{\epsilon}(g^{-1}(t))|J|=\exp(\frac{\log(t)-\mathbf{x^{\prime}}\bm {\beta}}{\sigma})\exp\biggl{[}-\exp(\frac{\log(t)-\mathbf{x^{\prime}}\mathbf{\beta}}{ \sigma})\biggr{]}\frac{1}{\sigma t}\] \[=(\frac{t}{\exp(\mathbf{x^{\prime}}\mathbf{\beta})})^{\frac{1}{\sigma}} \exp\biggl{[}-(\frac{t}{\exp(\mathbf{x^{\prime}}\mathbf{\beta})})^{\frac{1}{\sigma}} \biggr{]}\frac{1}{\sigma t}\] \[=\frac{1/\sigma}{\exp(\mathbf{x^{\prime}}\mathbf{\beta})}(\frac{t}{\exp( \mathbf{x^{\prime}}\mathbf{\beta})})^{\frac{1}{\sigma}-1}\exp\biggl{[}-(\frac{t}{\exp (\mathbf{x^{\prime}}\mathbf{\beta})})^{\frac{1}{\sigma}}\biggr{]} \tag{13}\]  
Comparing Equation (13) with Equation (2) and letting \(\gamma=\frac{1}{\sigma}\) and \(\rho=\exp(\mathbf{x^{\prime}}\mathbf{\beta})\), we can see \(T\) has a Weibull distribution \(T\sim W(\exp(\mathbf{x^{\prime}}\mathbf{\beta}),\frac{1}{\sigma})\). As shown in Equation (3), the survival function of \(T\sim W(\exp(\mathbf{x^{\prime}}\mathbf{\beta}),\frac{1}{\sigma})\) can be written as  
\[f_{e}(x)=\exp(x)\exp[-\exp(x)] \tag{9}\]0  
Referring to Equations (3) and (4), replacing \(\rho\) with \(\exp(\mathbf{x^{\prime}}\mathbf{\beta})\), and replacing \(\gamma\) with \(\frac{1}{\sigma}\), the expected survival time is given as:  
\[f_{e}(x)=\exp(x)\exp[-\exp(x)] \tag{9}\]1  
Since most statistical software use \(\log(T)\) to calculate the parameters, let us show the distribution and characteristics of \(\log(T)\). Let  
\[f_{e}(x)=\exp(x)\exp[-\exp(x)] \tag{9}\]2 \[f_{e}(x)=\exp(x)\exp[-\exp(x)] \tag{9}\]3 \[f_{e}(x)=\exp(x)\exp[-\exp(x)] \tag{9}\]4  
Substituting Equations (16) and (17) into Equation (9), we obtain:  
\[f_{e}(x)=\exp(x)\exp[-\exp(x)] \tag{9}\]5  
If we compare Equation (18) to Equation (5), we can see \(Y\) (i.e., \(\log(T)\)) has a \(G(\mathbf{x^{\prime}}\mathbf{\beta},\sigma)\) distribution. We can also observe the use of the error term \(\epsilon\), which follows a \(G(0,1)\) distribution in Equation (8). This is analogous to the error term in a simple linear regression, which has an \(N(0,\sigma^{2})\) distribution. Referring to Equations (13) and (18), we can see that in the Weibull AFT model, \(T\) has a Weibull \(W(\exp(\mathbf{x^{\prime}}\mathbf{\beta},\frac{1}{\sigma}))\) distribution, and \(\log(T)\) has a Gumbel \(G(\mathbf{x^{\prime}}\mathbf{\beta},\sigma)\) distribution.