Skip to contents

Density, distribution, and quantile functions for the gamma distribution, accepting either the native shape / rate (or scale) parameters or a mean and sd, which override them. Useful with distr() and add_integration(), where covariate moments come straight from a published baseline table. The moment parameterization uses shape = (mean / sd)^2 and rate = mean / sd^2.

Usage

qgamma(
  p,
  shape,
  rate = 1,
  scale = 1/rate,
  lower.tail = TRUE,
  log.p = FALSE,
  ...,
  mean,
  sd
)

pgamma(
  q,
  shape,
  rate = 1,
  scale = 1/rate,
  lower.tail = TRUE,
  log.p = FALSE,
  ...,
  mean,
  sd
)

dgamma(x, shape, rate = 1, scale = 1/rate, log = FALSE, ..., mean, sd)

Arguments

p

Vector of probabilities.

shape, rate, scale

See stats::GammaDist.

lower.tail, log.p, log

See stats::GammaDist.

...

Must be empty; it keeps mean and sd out of partial matching.

mean, sd

Mean and standard deviation, overriding shape and rate / scale when both are supplied. Both must be named in full.

x, q

Vector of quantiles.

Value

A numeric vector, as the corresponding stats function.

Examples

# Equivalent specifications
qgamma(0.5, mean = 65, sd = 8)
#> [1] 64.67209
qgamma(0.5, shape = (65 / 8)^2, rate = 65 / 8^2)
#> [1] 64.67209