I am interested in samples of $\theta$ from the posterior distribution
$$ P(\theta|x) = \int d\phi P(\theta|\phi)P(\phi|x) $$
where $x$ are data and $\phi$ are nuisance parameters. In principle, I can use a Metropolis Hastings sampler to sample from $\theta$ and $\phi$ and discard the samples of the nuisance parameter.
In this case, I can sample from $P(\phi|x)$ directly such that I can approximate the marginal posterior by Monte Carlo integration
$$ P(\theta|x)\approx\frac{1}{n}\sum_{i=1}^n P(\theta|\phi_i)\equiv \hat P, $$
where $\phi_i$ are samples from $P(\phi|x)$. Of course, the approximation $\hat P$ is not deterministic because of the sampling error. I seem to remember that running the following algorithm samples from the posterior in this case but I can no longer find the reference. Is this correct? If so, do you have a reference?
# Sampler in pseudo-python
theta = initial_value
for step in range(num_steps):
# Sample phi
phi = sample_phi_given_x(x)
# Evaluate current posterior
posterior_estimate = mean(posterior(theta, phi))
# Sampled from proposal and evaluate posterior at proposal
candidate = sample_from_proposal(theta)
posterior_candidate_estimate = mean(posterior(candidate, phi))
# Accept or reject the proposal
if random_uniform() < posterior_candidate_estimate / posterior_estimate:
theta = candidate
mean
will reduce the acceptance rate if the variance of the posterior associated with sampling $\phi$ is sufficiently large. In other words, the algorithm is hit by the curse of dimensionality. $\endgroup$