# What is the likelihood function of this random variable (beta distribution parameterizing a Bernoulli distribution)?

This is related to an earlier self-study question of mine. The setup is that there are $N$ individuals, indexed by $i$, and two time periods. Individuals choose whether to "invent" something in the second period (we assume that everyone invents in the first period) depending on whether their invention was successful in the first period.

Now for the math. Each individual has some "ability" parameter $p$ drawn from a beta distribution $B(a, b)$ and this ability parameter determines the success of their invention in the first period and thus whether they invent in the second period (based on updating their prior). $d_{i2}$ is the decision in the second period (1 is invent, 0 is to work and get the outside option $w$) and $x_{i1} = 1$ indicates success in the first period, 0 for failure.

From updating the conjugate prior I get that

$$P(d_{i2} = 1) = P \left(\frac{a + x_{i1}}{a+b+1} \geq w \right)$$

Here is where I got stuck. From the algebra I get $$P(d_{i2} = 1) = P \left( x_{i1} \geq w(a+b+1) - b \right)$$

To get the likelihood function, I need the CDF of $x_{i1}$ but I can't figure it out. I know $$x_{i1} = \begin{cases} 1 & \text{if } p_i > U[0,1] \\ 0 & \text{if } p_i \leq U[0,1] \end{cases}$$

But how do I translate this into a likelihood function?

The goal is to estimate the parameters $a$ and $b$ of the beta distribution using maximum likelihood, but all I observe in the dataset is the set of $d_{i2}$ (the set of $N$ decisions of whether individuals chose to invent in the second period).

• I replaced the image with LaTeX; if you just do \ begin{cases} ... \ end{cases} within math mode (without the spaces after the backslash) you can get the cases that you want – jld Apr 25 '18 at 15:39

When $P[x_i = 1] =p_i$ the (inverse) CDF of $x_i$ is: $$P[x_i \geq t] = \begin{cases} 1 & t < 0 \\ p_i & t \in [0,1]\\ 0 & t> 1\\ \end{cases}$$ Recall that we need to find $\rho_i = P[D_i=1] = P[x_i \geq w(a+b+1)-a]$, so we have: $$\begin{split} \rho_i(a,b;w)&= \begin{cases} 1 & w(a+b+1) < a \\ p_i & w(a+b+1) \in [a,a+1]\\ 0 & w(a+b+1)> a+1\\ \end{cases}\\ \end{split}$$
I think at this point it looks like your problem is ill-posed (as is). Ignoring the trivial cases of all $D_i = 1,0$, then the likelihood will be maxed only if $w(a+b+1) \in [a,a+1]$, but then the likelihood will depend purely on $p_i$:
$$\begin{split} \mathcal{L}(a,b;D,w)&=\prod\limits_i \rho_i(a,b;w)^{D_i} [1-\rho_i(a,b;w)]^{1-D_i}\\ &=\prod\limits_i p_i^{D_i} (1-p_i)^{1-D_i}\\ \end{split}$$
Since $p_i$ only depends on $a$ and $b$ through its distribution, in my opinion the way to deal with this is to maximize the expectation of $\mathcal{L}(a,b;D,w)$ over $p_i\sim \text{Beta}(a,b)$, rather than maximizing the $\mathcal{L}$ itself. This will be easier if we instead use the log-likelihood as our loss function: $$\mathcal{l}(a,b;D,w,p) = \sum\limits_i D_i \ln(p_i) + (1-D_i) \ln(1-p_i)$$
By linearity of expecation the expected log-likelihood (conditioned on $a$ and $b$) is then: $$\bar{l}(a,b;D,w) = \sum\limits_i D_i E_{a,b}[\ln(p_i)] + (1-D_i)E_{a,b}[\ln(1-p_i)]$$
Now note that $E_{a,b}[\ln(p_i)]$ is the negative entropy of a beta random variable with parameters $a$ and $b$, for which a closed form expression exists (although a messy one so I'm just gonna link to a Wikipedia page). Furthermore, since $1-p_i$ is also beta-distributed with parameters $b$ and $a$ (ie. we just swap the parameter values in the PDF) we can get an expression for $E_{a,b}[\ln(1-p_i)]$ in the same way, and maximize the resultant sum in $a$ and $b$.