I am trying to write a simple likelihood function to calculate the binomial probability of $X$ successes from $N$ trials. The problem is that the expected proportion of successes ($p_X$) is itself a binomially-distributed variable with $Y$ successes and $M$ trials.

That is, there a simple way to calculate $\text{E}(X)$ for $X\sim \text{Bin}(N, Y/M)$ when $Y\sim \text{Bin}(M, p)$?

Is it just the product of the two probabilities?

  • $\begingroup$ A binomial variable takes on values in ${0,1,2,\dots,M}$, and as such can't be an "expected proportion of successes". Do you perhaps mean that $Y/M$ is the expected proportion of successes? If so, this is an interesting model; could you explain a little how it comes about? $\endgroup$ – jbowman Nov 16 '13 at 1:21
  • $\begingroup$ Yes, Y/M is the expected proportion of successes. I am a geneticist and observe a mutation at frequency q from N individuals in population 1. From population 2, I observe the same mutation with frequency q from M individuals. I would like to calculate the probability of observing q (from N observations) conditional on the 'true' frequency being p. Of course, p is estimated with error so the binomial distribution doesn't seem quite right. $\endgroup$ – Alan Nov 16 '13 at 1:39
  • $\begingroup$ Can you ask about your actual problem (at this stage you may want to ask a new question)? I'd give a different answer to that. Note that either you condition on the observed $p$ (as you do ... and then don't ... in your question here), or you throw out your present formulation of the problem and actually deal with what now seems to be the underlying question (which seems to be 'do the samples suggest the two population frequencies differ?') ... a completely different problem. $\endgroup$ – Glen_b -Reinstate Monica Nov 21 '13 at 5:19

This can be done using the Law of Total Expectation.

$$\text{E} (X) = \text{E}_Y [ \text{E}_{X | Y} ( X | Y)]$$

Now $\text{E}_{X|Y}(X|Y)] = N\cdot p_x = N\cdot Y/M$, so

\begin{eqnarray} \text{E} (X) &=& \text{E}_Y [ N\cdot Y/M]\\ &=& \frac{N}{M}\cdot\text{E}_Y [Y]\\ &=& \frac{N}{M}\cdot (Mp)\\ &=& Np \end{eqnarray}

  • $\begingroup$ Thanks. I understand that E(X) = p; but the probability that E(X)=p is not just Bin(N,p), if p is a random variable itself, right? $\endgroup$ – Alan Nov 16 '13 at 16:02
  • $\begingroup$ Looks like you're getting muddled up. In the notation we have above, $p$ is the success probability for $Y$ and $Y/M$ (which is $p_X$) is the success probability for $X$. (You must distinguish those two probabilities; they're different values.) $E(X)$ is the expectation of $X$ unconditional on information about $Y$. $E(X|Y)$ is the expectation of $X$ given you know the value of $Y$. Are you now making not just $p_X$ random but also $p$? Then what's it's distribution? $\endgroup$ – Glen_b -Reinstate Monica Nov 16 '13 at 16:55
  • $\begingroup$ Alan, my earlier version omitted an important term; my apologies. Please take a look at the corrected answer. (That omission may have been part of the problem!) $\endgroup$ – Glen_b -Reinstate Monica Nov 16 '13 at 17:52
  • $\begingroup$ p is binomial, too. $\endgroup$ – Alan Nov 16 '13 at 21:59
  • $\begingroup$ Can you change your question to reflect the distribution for $p$ as well, because as it's written up there presently, $p$ is not random; my answer only answers the question that's actually there. Nevertheless, recursive application of the same law, properly applied, yields the answer for that case as well. $\endgroup$ – Glen_b -Reinstate Monica Nov 16 '13 at 23:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.