rweibullGF: Simulate random numbers from a Weibull distribution with...

View source: R/rweibullGF.R

rweibullGFR Documentation

Simulate random numbers from a Weibull distribution with gamma frailty

Description

Simulate random numbers from a Weibull distribution with gamma frailty

Usage

rweibullGF(n, rate, shape = 1, theta = 1)

Arguments

n

number of observations.

rate

rate parameter of the Weibull distribution.

shape

shape parameter of the Weibull distribution, with a default value of 1 (exponential).

theta

variance parameter of the gamma frailty distribution, with a default value of 1.

Details

Let \gamma denote a frailty term following a gamma distribution with shape = 1 / \theta and scale = \theta. Then \gamma has mean 1 and variance \theta.

Conditional on \gamma, the survival function is

S(t \mid \lambda, \alpha, \gamma) = \exp\left(-\gamma \lambda t^\alpha\right), \qquad \alpha > 0,\ \lambda > 0,

where \alpha is the shape parameter and \lambda is the rate parameter.

Integrating over the gamma frailty distribution gives the marginal survival function

S(t \mid \lambda, \alpha, \theta) = \left(1 + \theta \lambda t^\alpha\right)^{-1 / \theta}, \qquad \alpha > 0,\ \lambda > 0,\ \theta > 0.

This corresponds to the generalized log-logistic distribution (GLL) as implemented in GLL().

As \theta \to 0, this reduces to the standard Weibull distribution without frailty, with survival function

S(t \mid \lambda, \alpha) = \exp\left(-\lambda t^\alpha\right).

This corresponds to the Weibull distribution in stats::pweibull() with shape = shape and scale = rate^(-1 / shape).

When \theta = 1, the survival function becomes

S(t \mid \lambda, \alpha, 1) = \left(1 + \lambda t^\alpha\right)^{-1},

which is the survival function of a log-logistic distribution.

Value

a vector of random numbers of length n.

References

Wienke A. "Frailty Models in Survival Analysis." Chapman and Hall/CRC (2010).

See Also

simTTE() for simulation of a two-event time-to-event endpoint from this distribution under the illness-death model.

pGLL() provides the cumulative distribution function of the generalized log-logistic distribution.

Examples

## Example 1: each patient has a sampled time with potentially different
## shape, rate, and theta values.
set.seed(123)
n <- 1000
d <- data.frame(ID = 1:(2*n), TRTP = rep(c("A", "P"), each = n), 
rate = rep(c(0.1, 0.15), each = n), shape = 1.5, theta = 1)
d$time1 <- rweibullGF(n = 2*n, rate = d$rate, shape = d$shape, theta = d$theta)
tapply(d$time1, d$TRTP, summary)
## Example 2: all patients share the same parameter values.
d$time2 <- rweibullGF(n = 2*n, rate = 0.1, theta = 0)
tapply(d$time2, d$TRTP, summary)

hce documentation built on May 13, 2026, 9:06 a.m.