## Evaluating the posterior distribution

Evaluation of the posterior distribution and using it to obtain marginal posterior distributions for individual parameters relies heavily on integration. However, in most situations algebraic integration is not possible and a numerical method of integration is required.

An alternative approach that does not evaluate the full posterior distribution is known as empirical Bayes. We mention it here because it has been used a lot in the past owing to its ease of implementation. It works by first estimating the variance components from their marginal posterior distributions. The fixed effects are then obtained by conditioning the joint posterior distribution on the variance component estimates (i.e. evaluating the posterior distribution with the variance component parameters fixed at the estimated values). If a flat prior were assumed for all the model parameters, then the marginal posterior distribution for the variance components would be proportional to the REML and its mode would coincide with the REML variance component estimates. Thus, in this situation, a REML analysis is equivalent to an analysis using empirical Bayes. However, the benefits associated with using Bayesian models (e.g. exact standard deviations, probability intervals and significance test p-values) do not occur with empirical Bayes because the full conditional posterior distribution is not evaluated.

The most popular methods of evaluating the posterior now rely on simulation as a means of performing the integration. Such methods can be described as Monte Carlo methods and with the recent increased availability of computer power they have become much more feasible. Instead of seeking to obtain the marginal posterior distribution directly, random samples from the joint posterior density of all the model parameters are taken. Each sample provides a set of values of our model parameters (e.g. /, t, p, a2 and a2 in our cross-over example). If we are interested in the marginal distribution of t, say, then we simply ignore the other parameter values and consider only the randomly sampled values for t. Ifwe take a sufficiently large number of samples from the joint posterior density, then we will be able to characterise the marginal distribution of t, to whatever level of detail we wish. Of course, as well as estimating the marginal distributions (usually our main purpose) we can use the full set of values of our model parameters to evaluate the full posterior density.

It is not usually possible to define a process for sampling directly from the posterior density posterior distribution and various sampling approaches have been devised to overcome this difficulty. Some involve sampling a simpler 'base density' in place of the posterior density and accepting samples with probability proportional to the ratio of the posterior and base density. Independence chain sampling, importance sampling, rejection sampling and the random walk chain are all based on this approach. Alternatively, the sampling approach can be iterative so that samples are taken from the posterior distribution conditioned on the previous set of sampled values. Iterative approaches are often referred to as Markov chain Monte Carlo (MCMC) methods, the description 'Markov chain' being used because parameter values are sampled from a distribution depending only on parameter values sampled at the preceding iteration.

We will now describe the rejection sampling method and then an iterative method known as Gibbs sampling. More detail can be found in Tierney (1994), and in the following books: Markov Chain Monte Carlo in Practice by Gilks etal. (1995); Bayes and Empirical Bayes Methods for Data Analysis by Carlin and Louis (1996); and Methods for Exploration of Posterior Distributions and Likelihood Functions by Tanner (1996).