Evaluate conditional expectation using compound binomial random variables

binomial distributionconditional probabilityconditional-expectationprobabilityprobability distributions

$\DeclareMathOperator{\Bin}{Bin}$
I have two binomial random variables, $X \sim \Bin (n, p)$, and $Y \sim \Bin (X, q)$.

From this I can see that the conditional distribution of $Y|X$ is binomial,
i.e., $Y | X=x \sim \Bin (x, q)$. As I understand, here, Y is a conditional binomial where n = another binomial.

I also see from this previous discussion: https://stats.stackexchange.com/questions/112516/binomial-random-variable-conditional-on-another-one
that we can prove that the unconditional distribution of $Y$ is also binomial, i.e., $Y \sim \Bin (n, pq)$.

Now, I am trying to evaluate $E(X|Y)$ and I have to get it as a function of $Y$, or in terms of the distribution of a random variable that's known to us here. I tried the following:

$$E(X|Y=y) =
\sum_{x= 0}^n x P(X=x | Y=y)$$

To calculate $P(X=x | Y=y)$, I need $P(X=x, Y=y)$ and $P(Y=y)$.

To get $P(Y=y)$, I am using the unconditional distribution of $Y\sim \Bin(n, pq)$.

This gives me $P(Y=y) = \ ^nC_y \cdot (pq)^y \cdot (1-pq)^{n-y}$. (I wonder whether I can do this?)

Then, I calculate $P(X=x, Y=y) = P(Y=y | X=x) \cdot P(X=x)$

For this, I use $Y|X \sim \Bin(x, q)$, and $X \sim \Bin(n, p)$.

That is, $P(Y=y | X=x) = \ ^xC_y \cdot q^y \cdot (1-q)^{x-y}$, and $P(X=x) = \ ^nC_x \cdot p^x \cdot (1-p)^{n-x}$

When I worked it out, I am getting an expression for $P(X=x, Y=y)$, in terms of $n$, $x$, $y$, $p$, $q$, and $pq$, which doesn't seem to reduce to anything that's known (like, say, the pmf of a binomial).

Where am I going wrong here? I am ultimately trying to find $E(X|Y)$. I have been asked to use results regarding the conditional distribution, and also that the $E(X|Y)$ will be a function of $Y$. Thanks a ton for any help on figuring out what I am missing here…

Edit:

I also see that $E(E(X|Y)) = E(X) = np$, which means that $E(X|Y)$ is itself a binomial random variable. Is this relevant in any way for finding $E(X|Y)$?

Best Answer

If we take for granted that $$Y \sim \operatorname{Binomial}(n,pq),$$ then $$\Pr[X = x \mid Y = y] = \frac{\Pr[Y = y \mid X = x]\Pr[X = x]}{\Pr[Y = y]}, \tag{1}$$ by Bayes' theorem. And we have all of the relevant PMFs, so:

$$\begin{align} \Pr[X = x \mid Y = y] &= \frac{\binom{x}{y} q^y (1-q)^{x-y} \binom{n}{x} p^x (1-p)^{n-x}}{\binom{n}{y} (pq)^y (1-pq)^{n-y}}. \tag{2} \end{align}$$

Let's work out the binomial coefficients first. We have

$$\frac{\binom{x}{y} \binom{n}{x}}{\binom{n}{y}} = \frac{x!}{y!(x-y)!} \frac{n!}{x!(n-x)!} \frac{y!(n-y)!}{n!} = \frac{(n-y)!}{(x-y)!(n-x)!} = \binom{n-y}{x-y}. \tag{3}$$ This makes sense because we must remember that $0 \le Y \le X \le n$. So this suggests letting $m = n-y$, $w = x-y$, or equivalently, $$y = n-m, \quad x = w+y = n-m+w, \tag{4}$$ and writing the rest of the factors in $(2)$ as follows:

$$\begin{align} \frac{q^y(1-q)^{x-y} p^x (1-p)^{n-x}}{(pq)^y (1-pq)^{n-y}} &= \frac{q^y}{q^y} p^{x-y} (1-q)^{x-y} \frac{(1-p)^{n-x}}{(1-pq)^{n-y}} \\ &= \frac{(p(1-q))^{x-y} (1-p)^{m-w}}{(1-pq)^m} \\ &= \frac{(p(1-q))^w (1-p)^m}{(1-p)^w (1-pq)^m} \\ &= \left(\frac{p(1-q)}{1-p}\right)^w\left(\frac{1-p}{1-pq}\right)^m. \tag{5} \end{align}$$ We aren't quite done: If $m$ plays the role of the upper binomial coefficient argument, and $w$ plays the role of the lower, then our exponents in a corresponding binomial PMF should be $w$ and $m-w$, rather than $w$ and $m$. So we write $(5)$ as

$$\begin{align} \left(\frac{p(1-q)}{1-p}\right)^w\left(\frac{1-p}{1-pq}\right)^m &= \left(\left. \frac{p(1-q)}{1-p} \right/ \frac{1-p}{1-pq} \right)^w \left(\frac{1-p}{1-pq}\right)^{m-w} \\ &= \left(\frac{p(1-q)}{1-pq}\right)^w \left(\frac{1-p}{1-pq}\right)^{m-w} \\ &= s^w t^{m-w}, \end{align} \tag{6}$$ where $$s = \frac{p(1-q)}{1-pq}, \quad t = \frac{1-p}{1-pq}. \tag{7}$$ So putting this all together, $$\Pr[X = x \mid Y = y] = \binom{m}{w} s^w t^{m-w}. \tag{8}$$ It looks like it could be a binomial PMF, but is it? We need to check that $s + t = 1$. And it is: $$s + t = \frac{p(1-q)}{1-pq} + \frac{1-p}{1-pq} = \frac{p - pq + 1-p}{1-pq} = \frac{1-pq}{1-pq} = 1. \tag{9}$$ So we can write $(8)$ as $$\begin{align}\Pr[X = x \mid Y = y] &= \binom{m}{w} s^w (1-s)^{m-w}, \quad w \in \{0, 1, \ldots, m\} \\ &= \binom{n-y}{x-y} s^{x-y} (1-s)^{n-x}, \quad x \in \{y, y+1, \ldots, n\}. \tag{10} \end{align}$$ But $X \mid Y = y$ is not binomial, strictly speaking. It is a location-shifted binomial because the support is on $\{y, y+1, \ldots, n\}$, as $(10)$ above illustrates. This property is inherited from the earlier restriction $0 \le Y \le X \le n$, which in turn is due to the fact that $Y$ conditioned on $X$ cannot exceed $X$. Another way to conceptualize this is to see that once we have observed $Y = y$, this tells us that $X$ cannot be less than $y$, since then it would be impossible to have observed $Y = y$.

So we must write instead something like

$$(X - y) \mid Y = y \sim \operatorname{Binomial}\left( n-y, \frac{p(1-q)}{1-pq} \right). \tag{11}$$

This does not stop us from computing the conditional expectation, however. It is in fact immediate:

$$\operatorname{E}[X \mid Y = y] = \operatorname{E}[X - y \mid Y = y] + y = (n-y)\frac{p(1-q)}{1-pq} + y. \tag{12}$$ And we can now also write this in terms of the random variable $Y$ rather than a realization $y$:

$$\operatorname{E}[X \mid Y] = (n-Y)\frac{p(1-q)}{1-pq} + Y = \frac{1-p}{1-pq} Y + \frac{np(1-q)}{1-pq}. \tag{13}$$

Related Question