rgamma-distribution

Specify parameters of a gamma distribution given known median and mode


I need to specify a gamma distribution to represent a random variable in my modelling process. I have no data so cannot estimate parameters in a traditional way. All I know is that the mode must be 3 and the median must be 7.

Is there any way I can work backwards with this information to find the parameters of a gamma distribution that would have mode 4 and median 7?

I can code in R, so any computational methods are also greatly appreciated.

Thank you !


Solution

  • Use the closed-form solution for the mode to get one of the parameters in terms of the other, then solve for the CDF at 0.5 (median) with one of the parameters substituted out.

    f <- function(x) pgamma(7, x, (x - 1)/4) - 0.5
    (shape <- uniroot(f, c(1, 10))$root)
    # 1.905356
    (rate <- (shape - 1)/4)
    # 0.226339