Tags: ,

# Bayes’ theorem

Bayes’ theorem is formulated as $$P(A|B) =\frac{P(A\cap B)}{P(B)} =\frac{\frac{P(A\cap B)}{P(A)}P(A)}{P(B)} =\frac{P(B|A)}{P(B)}P(A)$$ where $P(\cdot)$ is the probability of a variable.

It is typically interpreted as $$P(H|E) =\frac{P(E|H)}{P(E)}P(H) =\frac{L(H|E)}{P(E)}P(H) \propto L(H|E)P(H)$$ where $H$ is a hypothesis, $E$ is evidence, $P(E|H)$ or $L(H|E)$ is the likelihood, $P(H)$ is the prior, and $P(H|E)$ is the posterior.

## Empirical Bayes method

Let $p(\cdot)$ be probability mass functions. Given observed data $y\sim p(y|\theta)$, parameters $\theta\sim p(\theta|\eta)$, and hyperparameters $\eta\sim p(\eta)$, we can obtain $$p(\theta|y) =\frac{p(y|\theta)}{p(y)}p(\theta) =\frac{p(y|\theta)}{p(y)}\int p(\theta|\eta)p(\eta)\,d\eta \label{eq:bayes_1}$$ because marginalizing out $\eta$ from the integral yields $$\int p(\theta|\eta)p(\eta)\,d\eta =\int\frac{p(\theta,\eta)}{p(\eta)}p(\eta)\,d\eta =\int p(\theta,\eta)\,d\eta =p(\theta).$$

Alternatively, $$p(\theta|y) =\int\frac{p(\theta,\eta,y)}{p(y)}\,d\eta =\int\frac{p(\theta,\eta,y)}{p(\eta,y)}\frac{p(\eta,y)}{p(y)}\,d\eta =\int p(\theta|\eta,y)p(\eta|y)\,d\eta$$ and from Eq. \eqref{eq:bayes_1}, \begin{aligned} p(\theta|y) &=\frac{p(y|\theta)}{p(y)}\int p(\theta|\eta)p(\eta)\,d\eta\\ &=\int\frac{p(y|\theta)p(\theta|\eta)}{p(y)}p(\eta)\,d\eta\\ &=\int\frac{p(y|\theta)p(\theta|\eta)}{p(y)}p(\eta)\frac{p(\eta,y)}{p(\eta,y)}\,d\eta\\ &=\int\frac{p(y|\theta)p(\theta|\eta)}{\frac{p(\eta,y)}{p(\eta)}}\frac{p(\eta,y)}{p(y)}\,d\eta\\ &=\int\frac{p(y|\theta)p(\theta|\eta)}{p(y|\eta)}p(\eta|y)\,d\eta\\ &=p(y|\theta)\int\frac{p(\theta|\eta)}{p(y|\eta)}p(\eta|y)\,d\eta. \end{aligned} \label{eq:bayes_2_1} From Eqs. \eqref{eq:bayes_1} and \eqref{eq:bayes_2_1}, $$p(\theta|y) =\int p(\theta|\eta,y)p(\eta|y)\,d\eta =p(y|\theta)\int\frac{p(\theta|\eta)}{p(y|\eta)}p(\eta|y)\,d\eta. \label{eq:bayes_2}$$

Note that $\eta$ and $y$ are conditionally independent when given $\theta$ because $y$ is generated from $\theta$, which in turn is sampled from $\eta$. When $\theta$ is given, $\eta$ will have no impact on $y$ and vice versa because the given $\theta$ is between $\eta$ and $y$. That is, $$p(\eta|\theta,y)=p(\eta|\theta).$$

Now, $p(\eta|y)$ in Eq. \eqref{eq:bayes_2} can be expressed as $$p(\eta|y) =\int p(\eta|\theta,y)p(\theta|y)\,d\theta =\int p(\eta|\theta)p(\theta|y)\,d\theta.$$