% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/GLL.R
\name{GLL}
\alias{GLL}
\alias{dGLL}
\alias{pGLL}
\alias{qGLL}
\alias{rGLL}
\alias{hGLL}
\alias{HGLL}
\title{The Generalized Log-Logistic Distribution}
\usage{
dGLL(x, rate, shape = 1, theta = 0, log = FALSE)

pGLL(q, rate, shape = 1, theta = 0)

qGLL(p, rate, shape = 1, theta = 0)

rGLL(n, rate, shape = 1, theta = 0)

hGLL(x, rate, shape = 1, theta = 0)

HGLL(x, rate, shape = 1, theta = 0)
}
\arguments{
\item{x, q}{vector of quantiles.}

\item{rate}{positive rate parameter of the distribution.}

\item{shape}{positive shape parameter of the distribution.}

\item{theta}{non-negative additional parameter of the distribution, with default
value \code{0}.}

\item{log}{logical; if \code{TRUE}, densities are given as logarithms.}

\item{p}{vector of probabilities.}

\item{n}{number of observations. Must be a single non-negative integer.}
}
\value{
For \code{dGLL()}, \code{pGLL()}, \code{qGLL()}, \code{hGLL()}, and \code{HGLL()}, a numeric vector of
the same length as the main input (\code{x}, \code{q}, or \code{p}). For \code{rGLL()}, a numeric
vector of length \code{n}.
}
\description{
Density, distribution function, quantile function, hazard, cumulative hazard,
and random generation for the generalized log-logistic distribution.
}
\details{
The generalized log-logistic distribution with rate parameter \eqn{\lambda > 0},
shape parameter \eqn{\alpha > 0}, and parameter \eqn{\theta \ge 0} has survival
function
\deqn{
S(t \mid \lambda, \alpha, \theta) =
\left(1 + \theta \lambda t^\alpha\right)^{-1 / \theta},
\qquad \theta > 0.
}

The corresponding cumulative distribution function is
\deqn{
F(t \mid \lambda, \alpha, \theta) =
1 - \left(1 + \theta \lambda t^\alpha\right)^{-1 / \theta}.
}

The quantile function is
\deqn{
Q(p \mid \lambda, \alpha, \theta) =
\left(
\frac{(1 - p)^{-\theta} - 1}{\theta \lambda}
\right)^{1 / \alpha},
\qquad 0 \le p \le 1,\ \theta > 0.
}

The cumulative hazard function is
\deqn{
H(t \mid \lambda, \alpha, \theta) =
\frac{\log\left(1 + \theta \lambda t^\alpha\right)}{\theta}.
}

The density function is
\deqn{
f(t \mid \lambda, \alpha, \theta) =
\lambda \alpha t^{\alpha - 1}
\left(1 + \theta \lambda t^\alpha\right)^{-1 / \theta - 1}.
}

For \code{dGLL(..., log = TRUE)}, the logarithm of the density is returned. For
\eqn{\theta > 0},
\deqn{
\log f(t \mid \lambda, \alpha, \theta) =
\log(\lambda) + \log(\alpha) + (\alpha - 1)\log(t)
- \left(\frac{1}{\theta} + 1\right)\log\left(1 + \theta \lambda t^\alpha\right).
}

The hazard function is
\deqn{
h(t \mid \lambda, \alpha, \theta) =
\frac{\lambda \alpha t^{\alpha - 1}}
{1 + \theta \lambda t^\alpha}.
}

Random generation is performed by inverse transform sampling. If
\eqn{U \sim \mathrm{Uniform}(0,1)}, then
\deqn{
T = Q(U \mid \lambda, \alpha, \theta)
}
has the generalized log-logistic distribution.

As \eqn{\theta \to 0}, this reduces to the Weibull distribution with survival
function
\deqn{
S(t \mid \lambda, \alpha) = \exp\left(-\lambda t^\alpha\right).
}
The corresponding quantile function is
\deqn{
Q(p \mid \lambda, \alpha) =
\left(
\frac{-\log(1 - p)}{\lambda}
\right)^{1 / \alpha}.
}
In this case, \code{dGLL(..., log = TRUE)} returns the corresponding Weibull
log-density.
This corresponds to the Weibull distribution in \code{\link[stats:dweibull]{stats::dweibull()}},
\code{\link[stats:pweibull]{stats::pweibull()}}, \code{\link[stats:qweibull]{stats::qweibull()}}, and \code{\link[stats:rweibull]{stats::rweibull()}} with
\code{shape = shape} and \code{scale = rate^(-1 / shape)}.

When \eqn{\theta = 1}, the survival function becomes
\deqn{
S(t \mid \lambda, \alpha, 1) = \left(1 + \lambda t^\alpha\right)^{-1},
}
corresponding to the log-logistic distribution.
}
\examples{
## Example 1: Compare the density of GLL with different values of `theta`
x <- seq(0, 10, length.out = 100)
y1 <- pGLL(x, rate = 0.5, shape = 2, theta = 1)
y0 <- pGLL(x, rate = 0.5, shape = 2, theta = 0)
plot(x, y1, type = "l", ylab = "Cumulative distribution function")
lines(x, y0, col = "red", lty = 2)
}
\references{
Wienke A. \emph{Frailty Models in Survival Analysis}. Chapman and Hall/CRC (2010).
}
\seealso{
\code{\link[=rweibullGF]{rweibullGF()}} for simulation of a Weibull distribution with gamma frailty.
}
