Amoud

The Generalized Log-logistic Distribution

The Generalized Log-logistic distribution is a generalization of the Log-logistic distribution which is obtained by adding an extra parameter to the hazard rate function of the log-logisitic distribution. Intriguingly, this straightforward modification adds an extra parameter that significantly increases the tractability of the hazard rate function. It is appealing for survival models because the hazard rate function of the Generalized Log-logistic distribution may represent the basic forms: constant, monotonic (increasing or decreasing), and non-monotonic (unimodal or bathtub) shapes.

The Generalized Log-logistic distribution is one of the distributions that can accommodate different hazard rate shapes and as well as closed under the hazard-based regression models including: accelerated failure time (AFT) (Muse, et al. 2022); proportional hazard (PH) (Muse, et al. 2022); and accelerated hazard (AH) models (Muse, et al. 2022).

The cumulative distribution function, probability density function, cumulative hazard function, and hazard rate function of the generalized log-logistic distribution are each provided by: \[ F(x ; \boldsymbol{\theta})=\frac{\left[1+(\eta x)^{\alpha}\right]^{\left(k^{\alpha} / \eta^{\alpha}\right)}-1}{\left[1+(\eta x)^{\alpha}\right]^{\left(\kappa^{\alpha} / \eta^{\alpha}\right)}}, \quad x \geq 0, \kappa, \alpha, \eta>0 \] \[ f(x ; \boldsymbol{\theta})=\frac{\alpha \kappa (\kappa x)^{\alpha-1}}{\left[1+(\eta x)^{\alpha}\right]^{\left(\kappa^{\alpha} / \eta^{\alpha}\right)+1}}, \quad x \geq 0, \kappa, \alpha, \eta > 0 . \] \[ H(x ; \boldsymbol{\theta})=\frac{\kappa^{\alpha}}{\eta^{\alpha}} \log \left[1+(\eta x)^{\alpha}\right], \quad x \geq 0, \kappa, \alpha, \eta>0 \] \[ h(x ; \boldsymbol{\theta})=\frac{\alpha \kappa(\kappa x)^{\alpha-1}}{\left[1+(\eta x)^{\alpha}\right]}, \quad x \geq 0, \kappa, \alpha, \eta>0 \] where \(\kappa >0, \alpha >0, \eta>0\) are parameters and \(\theta=(\kappa, \alpha, \eta)^{\prime}\).

Probabilistic Functions

The following R code contains an implementation of the cumulative distribution function, probability density function, quantile function, random number generation, hazard rate function,and cumulative hazard function of the Generalized Log-logistic distribution:

rm(list=ls())
#Required Packages
library(stats4)
library(bbmle)
library(stats)
library(numDeriv)
library(Matrix)
# t, q      : vector of quantiles.
# p         : vector of probabilities.
# n         : number of observations. 
# kappa : scale parameter
# alpha  : shape parameter
# eta  : power (shape) parameter

# Cumulative distribution function
cdf_GLL<-function(x,kappa, alpha, eta){
  (1-((1+((x*eta)^alpha))^(-((kappa^alpha)/(eta^alpha)))))
} 

# Probability density function
pdf_GLL<-function(x,kappa, alpha, eta){
  ((alpha*kappa)*((x*kappa)^(alpha-1)))/(1+((x*eta)^alpha))^(((kappa^alpha)/(eta^alpha))+1)
}

# Quantile function
GLL_quantile <- function(kappa,alpha,eta, u)
{
  num1 <- (eta^(alpha))/(kappa^(alpha))
  num2 <- (1/(1-u))^num1
  overall <- (num2-1)^(1/alpha)
  qfinal <- overall/eta
  return(qfinal)
} 

# Random number generation
rexpweibull<- function(n,kappa, alpha, eta){
  u= runif(n)
  sim <-  GLL_quantile(kappa,alpha,eta,u)
  return(sim)
} 

# Hazard function
hrf_GLL<-function(x,kappa, alpha, eta){
  ((alpha*kappa)*((x*kappa)^(alpha-1)))/(1+((x*eta)^alpha))
}                                                                                      

# Cumulative hazard function
CH_GLL<- function(x,kappa, alpha, eta){
  cdf <- (1-((1+((x*eta)^alpha))^(-((kappa^alpha)/(eta^alpha)))))
  return(-log(1-cdf))
} 

# Examples of the shape of the hazard function for different values of the parameters
h1 <- Vectorize(function(x) hrf_GLL(x,1.0,1.0,0.0))
h2 <- Vectorize(function(x) hrf_GLL(x,0.5,0.4,0.75))
h3 <- Vectorize(function(x) hrf_GLL(x,0.75,1.5,0.10))
h4 <- Vectorize(function(x) hrf_GLL(x,3.0,5.0,1.5))
h5 <- Vectorize(function(x) hrf_GLL(x,1.5,1.5,0.90 ))

#par(mfrow = c(3,2))
#1
curve(h1,0,5,ylim=c(0,2),col="black",lwd=2,n=1000,xlab="x",ylab="Hazard rate function",cex.axis=1.5,cex.lab=1.5)

#2
curve(h2,0,5,ylim=c(0,2),col="blue",lwd=2,n=1000,xlab="x",ylab="Hazard rate function",cex.axis=1.5,cex.lab=1.5)

#3
curve(h3,0,5,ylim=c(0,2),col="red",lwd=2,n=1000,xlab="x",ylab="Hazard rate function",cex.axis=1.5,cex.lab=1.5)

#4
curve(h4,-0.2,1,ylim=c(0,2.5),col="green",lwd=2,n=1000,xlab="x",ylab="Hazard rate function",cex.axis=1.5,cex.lab=1.5)

#5
curve(h5,0,5,ylim=c(0,2),col="purple",lwd=2,n=1000,xlab="x",ylab="Hazard rate function",cex.axis=1.5,cex.lab=1.5)

References

  1. Muse, A. H., Mwalili, S., Ngesa, O., Almalki, S. J., & Abd-Elmougod, G. A. (2021). Bayesian and classical inference for the generalized log-logistic distribution with applications to survival data. Computational Intelligence and Neuroscience, 2021.
  2. Muse, A. H., Mwalili, S., Ngesa, O., Alshanbari, H. M., Khosa, S. K., & Hussam, E. (2022). Bayesian and frequentist approach for the generalized log-logistic accelerated failure time model with applications to larynx-cancer patients. Alexandria Engineering Journal, 61(10), 7953-7978.
  3. Muse, A. H., Ngesa, O., Mwalili, S., Alshanbari, H. M., & El-Bagoury, A. A. H. (2022). A Flexible Bayesian Parametric Proportional Hazard Model: Simulation and Applications to Right-Censored Healthcare Data. Journal of Healthcare Engineering, 2022.
  4. Khan, S. A., & Khosa, S. K. (2016). Generalized log-logistic proportional hazard model with applications in survival analysis. Journal of Statistical Distributions and Applications, 3(1), 1-18.
  5. A. H. Muse, S. Mwalili, O. Ngesa, and M. Kilai, “AHSurv: Flexible Parametric Accelerated Hazards Models.,” R Packag. version 0.1.0;, 2022, [Online]. Available:AHSurv Package