Solution (source code)

= Solution

Use the shape-rate convention for every <gamma distribution>, with $a,c>0$. Let $A_i=a+y_i$ and $s=\sum_i\theta_i$. The <Poisson distribution> likelihood and the <Gamma–Poisson hierarchical model> give
$$
\pi(\theta,b\mid y)\propto
b^{na+c-1}e^{-b(1+s)}\prod_{i=1}^n\theta_i^{A_i-1}e^{-t_i\theta_i},
\qquad b>0,\ \theta_i>0.
$$
All factors involving the coordinate being updated must be retained, including $b^{na}$ from the conditional <gamma distributions>. The <full conditional distributions> are
$$
\boxed{\theta_i\mid b,y\sim\operatorname{Gamma}(A_i,b+t_i)\quad\text{independently},\qquad
b\mid\theta,y\sim\operatorname{Gamma}(na+c,1+s).}
$$
For a <blocked Gibbs sampler>, draw $b$ from the second <full conditional distribution>, then redraw all the $\theta_i$ independently from the first ones. Repeating these two steps preserves the joint <posterior distribution>; observing $\theta$ after each complete sweep gives the <Markov chain> used in the next part. Standard <gamma distribution> sampling works for noninteger as well as integer shapes. The positive observation-period convention $t_i>0$ is used for the subsequent <geometric drift condition>.