What's the likelihood function? Lactose intolerant exercise

105 Views Asked by At

It's an exercise from Bayes Rules! An Introduction to Bayesian Modeling with R.

Lactose intolerance is an inability to digest milk, often resulting in an upset stomach. Fatima wants to learn more about the proportion of adults who are lactose intolerant, $\pi$. Her prior model for $\pi$ is:

$\pi$ 0.4 0.5 0.6 0.7 Total
$f(\pi)$ 0.1 0.2 0.44 0.26 1

Fatima surveys a random sample of 80 adults and 47 are lactose intolerant.

How to calculate the likelihood in order to figure out the posterior model?

2

There are 2 best solutions below

3
On

Put $A = \{ $ 47 are intolerant and 33 are not $\}$.

$$P( A| \pi = p) = \binom{80}{33}p^{47}(1-p)^{33} $$ Hence we know $P( A| \pi = p)$ for all four values of $p$.

By Bayes' theorem, $$P(\pi= p | A) = \frac{ P( A| \pi = p) f(p) }{ \sum_j P( A| \pi = p_j) f(p_j) }$$

0
On

Fatima surveys a random sample of 80 adults and 47 are lactose intolerant.

Reading the observation's results, the likelihood is proportional to

$$l(\mathbf{x}|\pi)\propto\pi^{47}\cdot(1-\pi)^{33}$$

thus, conditional to the parameter values, we have that the likelihood is

$$\begin{cases} l(\mathbf{x}|\pi=0.4)\propto 0.4^{47}\cdot 0.6^{33} \\ l(\mathbf{x}|\pi=0.5)\propto 0.5^{80}\\ l(\mathbf{x}|\pi=0.6)\propto 0.6^{47}\cdot 0.4^{33}\\ l(\mathbf{x}|\pi=0.7)\propto 0.7^{47}\cdot 0.3^{33} \end{cases} $$

thus the posterior is

$$\begin{cases} p(\pi=0.4|\mathbf{x})\propto 0.1\cdot0.4^{47}\cdot 0.6^{33} \\ p(\pi=0.5|\mathbf{x})\propto 0.2\cdot0.5^{80}\\ p(\pi=0.6|\mathbf{x})\propto 0.44\cdot0.6^{47}\cdot 0.4^{33}\\ p(\pi=0.7|\mathbf{x})\propto 0.26\cdot0.7^{47}\cdot 0.3^{33} \end{cases} $$

Normalizing we get the desired posterior which is

$\pi|\mathbf{x}$ 0.4 0.5 0.6 0.7 Total
$p$ 0.001 0.114 0.834 0.052 1

the posterior normalization is calculated as follows

$$\frac{0.1\cdot0.4^{47}\cdot 0.6^{33}}{0.1\cdot0.4^{47}\cdot 0.6^{33}+ 0.2\cdot0.5^{80}+0.44\cdot0.6^{47}\cdot 0.4^{33}+0.26\cdot0.7^{47}\cdot 0.3^{33}}\approx 0.001$$


This is the drawing of Prior VS Posterior

enter image description here

As you can see, after data observations, the pmf is more concentrated around the mean