# Computing Posterior Probability of a Model being the correct one

Let $x\sim N(\mu,\sigma^2)$ and $\mu\sim N(\xi, \tau^2)$.

To test whether $\mu<0$ or $\mu>0$, in Bayesian inference it's usual to take the perspective of hypothesis testing as model selection. In that perspective,

$M_1:\mu<0$ and $M_2:\mu>0$ .

There are at least two ways to compute $P(M_{True}=M_1|x)$. The easy one seems to use the fact that $P(M_{True}=M_1|x)=P(\mu<0|x)=\Phi(-\xi(x)/w)$, since it's known that $\mu|x\sim N(\xi(x),w^2)$ .

(to save space-time I won't write $\xi(x)$ or $w$ formula)

The second way to calculate the $P(M_{True}=M_1|x)=\frac{\int l_k(\theta)\pi_k(\theta) d\theta \ \ P(M=k)}{\sum_j\int l_j(\theta)\pi_j(\theta) d\theta \ P(M=j)}$.

I'm trying to do by the second way. However, I get $P(M_{True}=M_1|x)=1-\Phi(-\xi(x)/w)=\Phi(\xi(x)/w)$

This is based on the book Bayesian Essentials, page 40.

Any help would be appreciated.

Edit: for the second way, we define $$\pi_1(\mu)=\frac{\exp\{-(\mu-\xi)^2/(2\tau^2\}}{(2\pi \tau^2)^{1/2}\Phi(-\xi/\tau)}\mathbb{I}_{\mu<0}$$ $$\pi_2(\mu)=\frac{\exp\{-(\mu-\xi)^2/(2\tau^2\}}{(2\pi \tau^2)^{1/2}\Phi(\xi/\tau)}\mathbb{I}_{\mu>0}$$

• For what its worth, I teach students to do the "easy one" as it seems very arbitrary to me to turn the question into a hypothesis testing question. Jan 23 '17 at 20:46
• For the second approach, I don't think you have defined enough. I'm assuming your priors for $\mu$ under the two models are the truncated versions of the prior for $\mu$ that you defined. I'm also assuming that the prior model probability is the integral of the defined prior with respect to that model. Jan 23 '17 at 20:49
• Uh? The equation (2.7) on page 40 does give $\Phi(-\xi(x)/w)$ as the answer. Jan 24 '17 at 7:34
• @jaradniemi I've added a few details. May you help me? Thanks Jan 24 '17 at 8:54
• @Xi'an I'm not sure I understand you. I don't manage to get the solution of the text by 2nd way... Jan 24 '17 at 8:56

You are correct in setting the restricted priors \begin{align*} \pi_1(\mu) &= \frac{\exp\{-(\mu-\xi)^2/(2\tau^2\}}{(2\pi \tau^2)^{1/2}\Phi(-\xi/\tau)}\mathbb{I}_{\mu<0}\\ \pi_2(\mu) &= \frac{\exp\{-(\mu-\xi)^2/(2\tau^2\}}{(2\pi \tau^2)^{1/2}\Phi(\xi/\tau)}\mathbb{I}_{\mu>0} \end{align*} Next step is identifying the prior weights \begin{align*} \mathbb{P}(\mathfrak{M}=M_1)&=\mathbb{P}(\mu<0)=\Phi(-\xi/\tau)\\ \mathbb{P}(\mathfrak{M}=M_2)&=\mathbb{P}(\mu>0)=\Phi(\xi/\tau) \end{align*} which leads to the posterior probability \begin{align*} \mathbb{P}(\mathfrak{M}=M_1|x)&\propto \int_{-\infty}^0 \varphi(\{x-\mu\}/\sigma) \pi_1(\mu)\,\text{d}\mu\times\mathbb{P}(\mathfrak{M}=M_1)=\int_{-\infty}^0 \varphi(\{x-\mu\}/\sigma) \pi(\mu)\,\text{d}\mu\\ \mathbb{P}(\mathfrak{M}=M_2|x)&\propto \int_0^\infty \varphi(\{x-\mu\}/\sigma) \pi_2(\mu)\,\text{d}\mu\times\mathbb{P}(\mathfrak{M}=M_2)=\int_0^\infty \varphi(\{x-\mu\}/\sigma) \pi(\mu)\,\text{d}\mu \end{align*} or [denoting $\mathfrak{m}(\cdot)$ for the marginal density of $X$] \begin{align*} \mathbb{P}(\mathfrak{M}=M_1|x)&\propto \mathfrak{m}(x) \int_{-\infty}^0 \pi(\mu|x)\,\text{d}\mu=\mathfrak{m}(x) \Phi(-\xi(x)/w)\\ \mathbb{P}(\mathfrak{M}=M_2|x)&\propto \mathfrak{m}(x)\int_0^\infty \pi(\mu|x)\,\text{d}\mu=\mathfrak{m}(x) \Phi(\xi(x)/w) \end{align*} which leads again to $$\mathbb{P}(\mathfrak{M}=M_1|x)=\Phi(-\xi(x)/w)$$
• Many thanks. I thought the prior weights could be anything as long as $P(M=M_1)=1-P(M=M_2)$... That's one of the reasons why I didn't get exactly the same. The other being a typo in my calculations. Now I get it. Thanks ;) Jan 24 '17 at 10:19