Relationship between Gibbs sampling and Metropolis-Hastings
Metropolis step for B
- Our target density to sample from is p(B | A, \text{data})
- This is the full conditional posterior for B because we are operating “within-Gibbs”
- Hastings ratio:
\alpha = \frac{p(B^* | A, \text{data})}{p(B_{\text{current}} | A, \text{data})} \frac{q(B_{\text{current}}| B^*)}{q(B^*|B_{\text{current}})}
- If we were able to sample from p(B|A, \text{data}) itself, then we could take that as the proposal, in which case:
\alpha = \frac{p(B^* | A, \text{data})}{p(B_{\text{current}} | A, \text{data})} \frac{p(B_{\text{current}}|A, \text{data})}{p(B^*|A, \text{data})} = 1
- Because \alpha=1 in that case, we would always accept the proposed value
- This means that a Gibbs step is a Metropolis step where we have used the full conditional posterior as the proposal
- Gibbs steps are a special case of independent Metropolis updates: the proposal does not depent on the previous value of the parameter
Postprocessing MCMC output
- Suppose we have a sample \{ \theta_t \}_{t=1}^T obtained from MCMC
- Assume everything checks out in terms of convergence, so \{ \theta_t \}_{t=1}^T \sim p(\theta | Y)
- Estimating posterior summaries? Use the MCMC sample
- Example. Estimate Pr(\theta > 0.9 | Y) using MCMC output:
\hat{Pr}(\theta > 0.9 | Y) = \frac{\sum_{t}^{T} 1_{\{\theta_t > 0.9\} }}{T}
- In R,
mean(theta_mcmc_sample > 0.9)
- Notice Pr(\theta > 0.9 | Y) = E(1_{ \{ \theta > 0.9 \} } | Y) and we are computing this expectation via a sample mean
- This is just like any Monte Carlo approximation