# Simulate a sample of the posterior predictive distribution in a Bayesian hierarchical model

Suppose the following Bayesian hierarchical model: $$Y|\lambda\sim\text{Pois}(\lambda)$$ $$\log(\lambda)|(\mu,\sigma)\sim N(\mu,\sigma)$$ $$\mu\sim N(0,10)$$ $$\sigma\sim\text{Gamma}(0.01,0.01).$$ Suppose an observation $y$ of $Y$. I am interested on the theoretical simulation of a sample from the posterior predictive distribution of $Y$, written as $p(\tilde{y}|y)$. Is the following procedure correct?

1. Take a sample from the posterior distribution of $\mu$ and $\sigma$ : $\mu^{(1)},\ldots,\mu^{(M)}$ and $\sigma^{(1)},\ldots,\sigma^{(M)}$ (assume we have it, from WinBUGS for example).

2. Generate an observation $\eta^{(i)}$ from $N(\mu^{(i)},\sigma^{(i)})$, $i=1,\ldots,M$.

3. Generate an observation $\gamma^{(i)}$ from $\text{Pois}(\exp(\eta^{(i)}))$, $i=1,\ldots,M$. Then $\gamma^{(1)},\ldots,\gamma^{(M)}$ is a sample from $Y$.

• That is correct, but I'd council strongly against your prior for $\sigma$; this is known to be problematic when there's any chance of $\sigma$ being near zero. Gelman has an article on Euclid projecteuclid.org/euclid.ba/1340371048 which talks about this, and there are other articles out there too. – jbowman May 25 '17 at 15:47
• Correct (but note the warning by @jbowman ) if $\mu$ and $\sigma$ are independent (as you surely know, just mentioning it for someone who may not be aware of this). – DeltaIV May 25 '17 at 16:14