Compute the shape and scale (or rate) parameters of the gamma distribution using method of moments for the random variable of interest.

mom_gamma(mean, sd, scale = TRUE)

## Arguments

mean Mean of the random variable. Standard deviation of the random variable. Logical. If TRUE (default), then the scale parameter is returned; otherwise, the rate parameter is returned.

## Value

If scale = TRUE, then a list containing the parameters shape and scale; otherwise, if scale = FALSE, then a list containing the parameters shape and rate.

## Details

If $$\mu$$ is the mean and $$\sigma$$ is the standard deviation of the random variable, then the method of moments estimates of the parameters shape = $$\alpha > 0$$ and scale = $$\theta > 0$$ are: $$\theta = \frac{\sigma^2}{\mu}$$ and $$\alpha = \frac{\mu}{\theta}$$

The inverse of the scale parameter, $$\beta = 1/\theta$$, is the rate parameter.

## Examples

mom_gamma(mean = 10000, sd = 2000)
#> $shape #> [1] 25 #> #>$scale
#> [1] 400
#> # The function is vectorized.
mom_gamma(mean = c(8000, 10000), sd = c(1500, 2000))
#> $shape #> [1] 28.44444 25.00000 #> #>$scale
#> [1] 281.25 400.00
#>