Hi,

I am working on writing a Gibbs sampler to do hypothesis testing in a Bayesian framework. I have a set of data which give the number of occurrences x in a sample of n trials. The particular model of interest is a three-layered hierarchical model with the following distributions:

1) The number of occurrences x given p is drawn from a Binomial distribution, f_{X|P}(x|p) = {n \choose x}p^{x}(1-p)^{n-x}.

2) The distribution of p given the hyperparameter m is a Beta distribution, f_{P|M}(p|m) = \frac{\Gamma(m)}{\Gamma(mq)\Gamma(m(1-q))} \; p^{mq-1}(1-p)^{m(1-q)-1}.
Here q is a known constant between 0 and 1. Note that the shape paramters \alpha = mq and \beta=m(1-q) are chosen so that the mean is q.

3) m is drawn from a uniform distribution f_{M}(m) on (\ell,\infty) where \ell=\max(1/q,1/(1-q)) which ensures that the distribution f_{P|M}(p|m) is concave.

If I am understanding the Gibbs sampling procedure correctly, it goes something like this.
Start by generating a value for m from the uniform distribution. Then:
1) Given this m generate a value for p from f_{P|M}(p|m).
2) Given p generate a value for x from f_{X|P}(x|p).
3) Given x generate a new value for p from f_{P|X}(p|x).
4) Given this new p generate a new value for m from f_{M|P}(m|p).
5) Repeat steps 1-4.

I am having trouble with step 4, since I need the conditional distribution f_{M|P}(m|p). I should be able to get this from Bayes theorem, since f_{M|P}(m|p) = \frac{f_{P|M}(p|m)f_{M}(m)}{\int  f_{P|M}(p|m)f_{M}(m)\mathrm{d}m}.

I have been unable to calculate the normalization integral that appears in the denominator above:

\int_{\ell}^{\infty} \; \frac{\Gamma(m)}{\Gamma(mq)<br />
\Gamma(m(1-q))} \;p^{mq-1}(1-p)^{m(1-q)-1}\; \mathrm{d}m.

Question 1: Does anyone know of a method to perform this integration of the Beta distribution with respect to m analytically? I have been unable to do so or find much on integration of the Beta distribution with respect to the shape parameter.

Question 2: For those readers who are familiar with Gibbs sampling and the Bayesian framework, please feel free to comment on the method of approach I outlined here. I am rather new at this and not entirely confident in the way I am attempting to do the sampling.

Thanks in advance,

basmati