Distributions – Ratio of Gamma Distributed Variables with Different Parameters

distributionsgamma distributionprior

I encounter a problem which I thought I can handle, however, I struggle a lot with finding a solution:

The following setting applies: I want to compute the posterior probability of an event, which is defined as the fraction of two distinct arrival rates of, lets say, some agents. So I define as priors for the arrival rates $\mu$ and $\varepsilon$ Gamma distributions with parameters $\mu\sim G(\alpha_\mu,\beta)$ and $\varepsilon\sim G(\alpha_\varepsilon,\beta)$.

The event I am interested in depends on some constant $1>c>0$ and is characterized by $$P = \frac{c(\varepsilon+\mu)}{\varepsilon + c\mu}.$$
Well, the nominator takes the form $c(\varepsilon+\mu) \sim G(\alpha_\mu + \alpha_\varepsilon, \frac{\beta}{c})$, however, as the two parts in the denominator do not have the identical scale parameter I cannot simply identify the distribution of $P$ as a beta distribution as would be the case given I would simply compute $\frac{x}{y+x}$ with $x\sim G(\alpha_1,\theta), y\sim G(\alpha_2,\theta)$.

Is there any way to overcome this problem and to find the probability distribution of $P$? Or, is there another distribution which would give me some closed form solutions for $P$?

Best Answer

You could think of approximating it using Kernel Density Estimation. Since you can easily simulate gamma variates, then you can easily simulate from P. Using a simulated sample, you can then construct a nonparametric estimator of this density. The following R code shows the approximation using 100,000 simulations (quite a few).

# Parameters
a.mu = 5
a.eps = 5
beta = 5
c = 0.5
# Number of simulations
N = 100000

# Simulated P
mu = rgamma(N,a.mu,beta)
eps = rgamma(N,a.eps,beta)
P.sim = c*(eps+mu)/(eps+c*mu) 

# Bandwidth
h = bw.nrd0(P.sim)

# Kernel density estimator
denP = Vectorize(function(t)  mean(dnorm(t-P.sim,0,h)) )

# Fit
hist(P.sim,probability=T,ylim=c(0,6))
curve(denP,0,1,lwd=2,add=T)
Related Question