Pseudo-marginal Metropolis–Hastings algorithm

In computational statistics, the pseudo-marginal Metropolis–Hastings algorithm is a Monte Carlo method to sample from a probability distribution. It is an instance of the popular Metropolis–Hastings algorithm that extends its use to cases where the target density is not available analytically. It relies on the fact that the Metropolis–Hastings algorithm can still sample from the correct target distribution if the target density in the acceptance ratio is replaced by an estimate. It is especially popular in Bayesian statistics, where it is applied if the likelihood function is not tractable (see example below).

Algorithm description
The aim is to simulate from some probability density function $$\pi(\theta) $$. The algorithm follows the same steps as the standard Metropolis–Hastings algorithm except that the evaluation of the target density is replaced by a non-negative and unbiased estimate. For comparison, the main steps of a Metropolis–Hastings algorithm are outlined below.

Metropolis–Hastings algorithm
Given a current state $$\theta_n$$ the Metropolis–Hastings algorithm proposes a new state according to some density $$\theta'\sim Q( \cdot \mid \theta_n)$$. The algorithm then sets $$\theta_{n+1} = \theta'$$ with probability


 * $$a(\theta_n, \theta') = \min\left(1,\frac{\pi(\theta')}{\pi(\theta_n)}\frac{Q(\theta_n\mid\theta')}{Q(\theta'\mid\theta_n)}\right) $$

otherwise the old state is kept, that is, $$\theta_{n+1}=\theta_n$$.

Pseudo-marginal Metropolis–Hastings algorithm
If the density $$\pi$$ is not available analytically the above algorithm cannot be employed. The pseudo-marginal Metropolis–Hastings algorithm in contrast only assumes the existence of an unbiased estimator $$\hat{\pi}_\theta$$, i.e. the estimator must satisfy the equation $$\mathbb{E}[\hat{\pi}_\theta] = \pi(\theta).$$ Now, given $$\theta_n$$  and the respective estimate  $$\hat{\pi}_{\theta_n}$$ the algorithm proposes a new state according to some density $$\theta'\sim Q( \cdot \mid \theta_n)$$. Next, compute an estimate $$\hat{\pi}_{\theta'}$$ and set $$\theta_{n+1} = \theta'$$ with probability


 * $$ a(\theta_n, \theta') = \min\left( 1, \frac{\hat{\pi}_{\theta'}}{\hat{\pi}_{\theta_n}} \frac{Q(\theta_n\mid\theta')}{Q(\theta'\mid\theta_n)}\right) $$

otherwise the old state is kept, that is, $$\theta_{n+1}=\theta_n$$.

Application to Bayesian statistics
In Bayesian statistics the target of inference is the posterior distribution


 * $$p(\theta \mid y) = \frac{p_\theta(y)p(\theta)}{p(y)},$$

where $$p_\theta$$ denotes the likelihood function, $$p$$ is the prior and $$p(y)$$ is the prior predictive distribution. Since there is often no analytic expression of this quantity, one often relies on Monte Carlo methods to sample from the distribution instead. Monte Carlo methods often need the likelihood $$p_\theta(y)$$ to be accessible for every parameter value $$\theta$$. In some cases, however, the likelihood does not have an analytic expression. An example of such a case is outlined below.

Example: Latent variable model
Consider a model consisting of i.i.d. latent real-valued random variables $$Z_1,\ldots,Z_n$$ with $$Z_i \sim f_\theta(\cdot)$$ and suppose one can only observe these variables through some additional noise $$Y_i \mid Z_i = z \sim g_\theta(\cdot\mid z)$$ for some conditional density $$g$$. (This could be due to measurement error, for instance.) We are interested in Bayesian analysis of this model based on some observed data $$y_1, \ldots, y_n$$. Therefore, we introduce some prior distribution $$p(\theta)$$ on the parameter. In order to compute the posterior distribution


 * $$p(\theta \mid y_1, \ldots, y_n) \propto p_\theta(y_1, \ldots, y_n) p(\theta) $$

we need to find the likelihood function $$p_\theta(y_1, \ldots, y_n)$$. The likelihood contribution of any observed data point $$y$$ is then


 * $$p_\theta(y) = \int g_\theta(y \mid z)f_\theta(z) \, dz $$

and the joint likelihood of the observed data $$y_1, \ldots, y_n$$ is


 * $$p_\theta(y_1, \ldots, y_n) = \prod_{i=1}^n p_\theta(y_i) = \prod_{i=1}^n \int g_\theta(y_i \mid z_i)f_\theta(z_i) \, dz_i.$$

If the integral on the right-hand side is not analytically available, importance sampling can be used to estimate the likelihood. Introduce an auxiliary distribution $$q$$ such that $$g_\theta(y\mid z)f_\theta(z) > 0 \Rightarrow q(z) > 0 $$ for all $$z$$ then


 * $$\hat{p}_\theta(y_i)=\frac{1}{N}\sum_{k=1}^N \frac{g_\theta(y_i \mid Z_k)f_\theta(Z_k)}{q(Z_k)}, \qquad Z_k \overset{i.i.d.}{\sim} q(\cdot)$$

is an unbiased estimator of $$p_\theta(y_i)$$ and the joint likelihood can be estimated unbiasedly by


 * $$\hat{p}_\theta(y_1, \ldots, y_n) = \prod_{i=1}^n \hat{p}_\theta(y_i) = \prod_{i=1}^n \frac{1}{N} \sum_{k=1}^N \frac{g_\theta(y_i \mid Z_{i,k}) f_\theta(Z_{i,k})}{q(Z_{i,k})}, \qquad Z_{i,k} \overset{i.i.d.}{\sim} q(\cdot).$$

Extensions
Pseudo-marginal Metropolis-Hastings can be seen as a special case of so-called particle marginal Metropolis-Hastings algorithms. In the case of the latter, unbiased estimators of densities relating to static parameters in state-space models may be obtained using a particle filter. While the algorithm enables inference on both the joint space of static parameters and latent variables, when interest is only in the static parameters the algorithm is equivalent to a pseudo-marginal algorithm.