In the context of Bayes estimation via Gibbs sampling, with or without
data augmentation, a simple approach is developed for computing the m
arginal density of the sample data (marginal likelihood) given paramet
er draws from the posterior distribution. Consequently, Bayes factors
for model comparisons can be routinely computed as a by-product of the
simulation. Hitherto, this calculation has proved extremely challengi
ng. Our approach exploits the fact that the marginal density can be ex
pressed as the prior times the likelihood function over the posterior
density. This simple identity holds for any parameter value. An estima
te of the posterior density is shown to be available if all complete c
onditional densities used in the Gibbs sampler have closed-form expres
sions. To improve accuracy, the posterior density is estimated at a hi
gh density point, and the numerical standard error of resulting estima
te is derived. The ideas are applied to probit regression and finite m
ixture models.