# Conditional Distribution to sample

Suppose I have six data points (n,x):

(14,5),

(13,4),

(7,3),

(10,5),

(12,7),

(20,13)

which are realizations of binomial experiments on n trials with x successes respectively..

And I assume I have a prior on the proportion of successes, p.

Such that $$0 \le p_{1} \lt p_{2} \lt p_{3} \lt p_{4} \lt p_{5} \lt p_{6} \le 1$$

For which we have an observed initial value from the above data.

So for each $$p_{i}$$, we have that it is conditional uniform on the two other close.

For example, $$Pr(p_{3}|p_{1},p_{2},p_{4},p_{5},p_{6}) \sim U(p_{2},p_{4})$$

I want to gibbs sample, so I need the conditional distributions,

my question is do I need to include the binomial portion in each for example would I need to do

$$Pr(p_{3}|p_{1},p_{2},p_{4},p_{5},p_{6},X)$$ ,ie with X included. If so, how would I incorporate it , would I only use that binomial corresponding to the third collection of data points? Or would I multiply by binomial for the first , second fourth and fifth collection

Someone suggested I find the joint posterior before full. I do not understand what is meant by that.

For the binomial for example, how do I incorporate it? Like for the first and second

$${14 \choose x_{1}}p_{1}^{x_{1}}(1-p_{1})^{14-x_{1}}$$

$${13 \choose x_{2}}p_{2}^{x_{2}}(1-p_{2})^{13-x_{2}}$$

and so forth. Would I just multiply these?

$$Pr(p_{1},p_{2},p_{3},p_{4},p_{5},p_{6})= c I(0 \le p_{1} \lt p_{2}...\lt p_{6} \le 1)$$ but I don't know how to find c, nor what order to approach the problem

So would the joint posterior then be $$p(p_{1:6}|x_{1:6})$$

proportional to

$$f(x_{1:6}|p_{1:6})I(0 \le p_{1} \lt p_{2})I(p_{2} \lt p_{3})...I(p_{6} \le 1)$$

Hence it seems it would be product of the binomials times the indicator type function.What distribution would this be though? Where do I incorporate the observed data?

It seems like I need to have $$Pr(p_{1}|p_{2},p_{3},p_{4},p_{5},p_{6},X)$$ , where X is the data, but i have literally no idea at all how to do this. I am completely lost. Would I multiply by all the other binomial probabilities? But which do I plug in? I don't know how I would implement this in R or a program to do gibbs sampling

I really appreciate any help at all, I have been trying to get some help here for many days, any hints or ideas that I can understand

• I suggest you start by writing the joint posterior of $p_{1:5}$ before asking for the full conditional. – Xi'an Dec 2 '18 at 13:45
• Is what I added what you meant by joint posterior? I am a bit confused what you mean by finding that before the full conditional. What is the difference? – Learning Dec 2 '18 at 20:39
• I am really trying to understand, but I just cant seem to. Can you please try to help explain a bit more? I want to work through it but I am stuck. I dont know how to condition. Do we take the values from the data given and condition on that or what? I am totally lost – Learning Dec 2 '18 at 20:52
• @Xi'an . I think I see what you meant, I updated again. Hopefully someone can help me to understand what I am missing or need to do. Thank you very much for your time – Learning Dec 2 '18 at 21:58
• Been working all day on it and I am simply stuck. I have tried all I know. – Learning Dec 3 '18 at 4:02

Likelihood $$\prod_{i=1}^6 p_i^{x_i}(1-p_i)^{n_i-x_i}$$ Prior $$\mathbb{I}_{0 \le p_{1} \lt p_{2}...\lt p_{6} \le 1}$$ Posterior $$\prod_{i=1}^6 p_i^{x_i}(1-p_i)^{n_i-x_i} \times \mathbb{I}_{0 \le p_{1} \lt p_{2}...\lt p_{6} \le 1}$$ Conditional $$p_i|p_{-i},\mathbf{x} \sim p_i^{x_i}(1-p_i)^{n_i-x_i}\times \mathbb{I}_{p_{i-1}\le p_i\le p_{i+1}}$$ Hence this is a truncated Beta distribution that can be easily simulated in R with the inverse cdf method and the qbeta R function.