# The PDF of the Data (Marginal Likelihood) Given the Prior of a Gamma Distribution with Prior on the $\beta$ Paraneter

Given a model where $$x_i | \beta \sim \mathcal{Gamma} ( \alpha, \beta )$$ where $$\beta \sim \mathcal{Gamma} ( \alpha0, \beta0 )$$, is there a closed form formula for the PDF of $$x_i$$?

Namely, what's $$p ( x_i )$$?

In the Gamma Distribution above I assume the shape ($$\alpha$$) and rate ($$\beta$$) variant of the Gamma Distribution.

This is similar to a different question I asked (The PDF of the Data Given (Marginal Likelihood) the Likelihood and the Prior of a Normal Distribution with Prior on the Mean) yet with totally different model (This is about the conjugate prior Gamma Gamma model and the other question about the Normal Normal conjugate prior model). I am using this to build a model of my data (2 different sets in each question). Please unlock this question.

• I agree it's a (slightly) different question. However, it has at least four distinct interpretations: please explain the meaning of your parameters. (Which is a shape, which is a rate, which is a scale?)
– whuber
Commented Apr 22, 2022 at 21:02
• @whuber, I updated the question to clarify the model of parameters assumed in the question (Link to Wikipedia for clarity). Commented Apr 22, 2022 at 21:47

Yes it does, the Generalized Beta prime distribution with shape parameter equal to 1.

We can get there fairly easily by integrating $$\beta$$ out of the joint distribution of $$x$$ and $$\beta$$:

$$f(x,\beta|\alpha, \alpha_0, \beta_0) = {\beta^{\alpha}x^{\alpha-1} \over \Gamma(\alpha)}e^{-\beta x}{\beta_0^{\alpha_0}\beta^{\alpha_0-1} \over \Gamma{\alpha_0}}e^{-\beta_0\beta}$$

Rearranging terms and ignoring everything that isn't related to either $$\beta$$ or $$x$$ (as they will all be handled by the constant of integration at the end) results in a great deal of simplification:

$$f(x,\beta|\cdot) \propto x^{\alpha-1}\beta^{\alpha+\alpha_0-1}e^{-(\beta_0+x)\beta}$$

We can integrate out $$\beta$$ easily enough by noting that the two terms involving $$\beta$$ are those of a Gamma-distributed variate with shape parameter $$\alpha + \alpha_0$$ and rate parameter $$\beta_0 + x$$, so the integral must equal the inverse of the constant of integration of such a distribution:

$$x^{\alpha-1}\int \beta^{\alpha+\alpha_0-1}e^{-(\beta_0+x)\beta}\text{d}\beta = {x^{\alpha-1} \Gamma(\alpha+\alpha_0) \over(\beta_0 + x)^{\alpha + \alpha_0}} \propto x^{\alpha-1} (\beta_0 + x)^{-\alpha - \alpha_0}$$

A slight rearrangement of terms and some minor algebra gets us to:

$$f(x|\cdot) \propto \left({x \over \beta_0}\right)^{\alpha-1} \left(1 + {x\over \beta_0}\right)^{-\alpha - \alpha_0}$$

which clearly matches the formula for the GBPD (with shape parameter $$p=1$$) as given by Wikipedia and reproduced here:

$$f(x;\alpha,\beta,p,q) = \frac{p \left(\frac x q \right)^{\alpha p-1} \left(1+ \left(\frac x q \right)^p\right)^{-\alpha -\beta}}{qB(\alpha,\beta)}$$

• This is great. First, Interesting that this is the conjugate of the Bernoulli distribution in its odds variant. Is there a meaning to that? When you mark proportionally, does it mean that the model is equivalent to GBPD(alpha, alpha0, 1, beta0)? Commented Apr 25, 2022 at 8:55
• 1) Yes, it is interesting, and I can't for the life of me figure out what it means. 2) Yes, the model is equivalent to a GBPD(alpha, alpha0, 1, beta0). Remarkably enough, I've actually had occasion to use it in my applied work... Commented Apr 25, 2022 at 14:36
• May I ask for what purpose did you use the model? Commented Apr 25, 2022 at 19:16
• Related to inventory control - a common assumption is that demand ~ Negative Binomial, but items are often shipped in case packs that are much larger than the demand rate. What is the distribution of the time until enough demands have occurred to trigger an order for a full case pack? If you have that distribution, you can better predict when you need inventory in a distribution center for satisfying store orders on the DC. $\beta$ = the case pack qty, etc. You can get there via Poisson demand with rate ~ Gamma and the Gamma scale parameter in turn distributed Gamma. Commented Apr 25, 2022 at 20:12