Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gamma_params

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


Description

Function to calculate the shape, α, and scale, θ, (or rate, β) parameters of a gamma distribution based on the method of moments (MoM) using the mean μ and standard deviation σ 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 the gamma distribution (Default is TRUE). If FALSE, rate parameterization is retrieved

Value

A list contianing the following:

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 μ is the mean and σ is the standard deviation of the random variable, then the the shape, α, scale, θ, and rate, β, parameters are computed as follows

α=\frac{μ^2}{σ^2},

θ = \frac{σ^2}{μ}

and

β = \frac{μ}{σ^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

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

dampack

Decision-Analytic Modeling Package

v1.0.0
GPL-3
Authors
Fernando Alarid-Escudero [aut], Greg Knowlton [aut, cre], Caleb Easterly [aut], Eva Enns [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.