Let $a, c$ and $d$ be positive real numbers. Let us also assume that $b \sim \Gamma (c, d) $. Next, let us define random variable $X \sim \Gamma (a, b)$. Then we would like to know the probability density function of $X$ given $b$.
I wanted to use somehow the following identity
$$ \mathbb{P} ( X \leq x ) = \int_{0}^{\infty} \mathbb{P} ( X \leq x | b = z) f_{b} (z) \ dz . $$
However, I don't know whether I am expressing $\mathbb{P} ( X \leq x | b = z)$ correctly and I get some difficult integrals. I tried to differentiate the identity above with respect to $x$ to get the probability density function, but I got something resembling the probability density function of Beta distribution. I would appreciate any help or advice.
You want the marginal (unconditional) density for a hierarchical model for a gamma density whose rate parameter is also gamma: $$X \mid B \sim \operatorname{Gamma}(a,B), \\ B \sim \operatorname{Gamma}(c,d), \\ f_{X\mid B}(x\mid b) = \frac{b^a x^{a-1} e^{-bx}}{\Gamma(a)}, \\ f_B(b) = \frac{d^c b^{c-1} e^{-db}}{\Gamma(c)}.$$ We note that the marginal density is $$\begin{align} f_X(x) &= \int_{b=0}^\infty f_{X \mid B}(x \mid b) f_B(b) \, db \\ &= \frac{d^c x^{a-1}}{\Gamma(a)\Gamma(c)} \int_{b=0}^\infty b^{a+c-1} e^{-(x+d)b} \, db \\ &= \frac{\Gamma(a+c) d^c x^{a-1}}{\Gamma(a)\Gamma(c)(x+d)^{a+c}} \int_{b=0}^\infty \frac{(x+d)^{a+c} b^{a+c-1} e^{-(x+d)b}}{\Gamma(a+c)} \, db \\ &= \frac{\Gamma(a+c) d^c x^{a-1}}{\Gamma(a)\Gamma(c) (x+d)^{a+c}}. \tag{1} \end{align}$$
The support is on $x \in (0,\infty)$, so this is not beta distributed. Instead, this is known as a generalized beta prime distribution or compound gamma distribution. The latter is a special case of the former with $p = 1$.