gamma_params: Calculate shape and scale (or rate) parameters of a gamma...

View source: R/gamma_params.R

gamma_paramsR Documentation

Calculate shape and scale (or rate) parameters of a gamma distribution.

Description

Function to calculate the shape, \alpha, and scale, \theta, (or rate, \beta) parameteres of a gamma distribution based on the method of moments (MoM) using the mean \mu and standard deviation \sigma of the random variable of interest.

Usage

gamma_params(mu, sigma, scale = TRUE)

Arguments

mu

Scalar with the mean of the random variable.

sigma

Scalar with the standard deviation of the random variable.

scale

Logical variable indicating scale parameterization of gamma distribution (Default is TRUE). If FALSE, rate parameterization is retrieved

Value

shape Shape parameter of gamma distribution scale Scale parameter of gamma distribution (If scale=TRUE) rate Rate parameter of gamma distribution (If scale=FALSE)

Details

Based on method of moments. If \mu is the mean and \sigma is the standard deviation of the random variable, then the the shape, \alpha, scale, \theta, and rate, \beta, parameteres are computed as follows

\alpha=\frac{\mu^2}{\sigma^2},

\theta = \frac{\sigma^2}{\mu}

and

\beta = \frac{\mu}{\sigma^2}

References

  • Gamma distribution. (2018, February 7). In Wikipedia, The Free Encyclopedia. Retrieved 17:23, February 11, 2018, from https://en.wikipedia.org/w/index.php?title=Gamma_distribution&oldid=824541785

Examples

## Not run: 
mu    <- 2
sigma <- 1
# Scale specification 
gamma_params(mu, sigma)
# Rate specification 
gamma_params(mu, sigma, scale = FALSE)

## End(Not run)

feralaes/dampack documentation built on Sept. 8, 2024, 11:31 a.m.