2
$\begingroup$

(From Bayesian Essentials with R by Marin & Robert page 31)

We are given an iid sample $\mathfrak{D}_n = (x_1, \dots, x_n)$ from the normal distribution $\mathcal{N}(0, \sigma^2)$ and $\theta=(\mu, \sigma^2)$, prior distribution $\mathcal{N}(0, \sigma^2)$ on $\mu$, and exponential distribution $\mathcal{E}(1)$ for $\sigma^{-2}$.

Corresponding posterior density on $\theta$ is then given by \begin{align*} \pi((\mu, \sigma^2) | \mathfrak{D}_n) &\propto \pi(\sigma^2) \times \pi(\mu | \sigma^2) \times l((\mu, \sigma^2) | \mathfrak{D}_n)\\ &\propto (\sigma^{-2})^{(1/2 + 2)} \exp \big\{ -(\mu^2 + 2) / 2\sigma^2 \big\} \\ &\times (\sigma^{-2})^{n/2} \exp \big\{ -(n(\mu - \bar{x})^2 + s^2) / 2\sigma^2 \big\}\cdots (\textbf{eq1})\\ &\propto (\sigma^2)^{-(n+5)/2} \exp \big\{ -\big[ (n+1)(\mu-n\bar{x}/(n+1))^2 + (2+s^2) \big] /2\sigma^2\big\} \cdots (\textbf{eq2})\\ &\propto (\sigma^2)^{-1/2} \exp \big\{ -(n+1)\big[ \mu - n\bar{x}/(n+1)\big]^2 / 2\sigma^2 \big\} \times (\sigma^2)^{-(n+2)/2-1} \exp \big\{ -(2+s^2) / 2\sigma^2 \big\} \end{align*}

I am having trouble getting to eq2 from eq1. \begin{align} &(\sigma^{-2})^{(1/2 + 2)} \exp \big\{ -(\mu^2 + 2) / 2\sigma^2 \big\} \times (\sigma^{-2})^{n/2} \exp \big\{ -(n(\mu - \bar{x})^2 + s^2) / 2\sigma^2 \big\}\cdots (\textbf{eq1})\\ &=(\sigma^2)^{-(n+5)/2} \exp \big\{ (-\mu^2 -2 -n(\mu-\bar{x})^2 - s^2) / 2\sigma^2 \big\}\\ &=(\sigma^2)^{-(n+5)/2} \exp \big\{ (-\mu^2 -n(\mu-\bar{x})^2 -(2+ s^2) / 2\sigma^2 \big\} \end{align} We then try to complete the square in $-\mu^2 -n(\mu-\bar{x})^2$ \begin{align} (-\mu^2 -n(\mu-\bar{x})^2) &= -\mu^2 -n\mu^2 + 2n\mu\bar{x} - \bar{x}^2n \\ &= -(n+1) \mu^2 + 2n\mu\bar{x} - \bar{x}^2n\\ &= -(n+1)(\mu^2 - {2n\mu\bar{x} \over n+1} + {n^2\bar{x}^2 \over (n+1)^2}) + {n^2\bar{x}^2 \over n+1} - \bar{x}^2n \\ &= - (n+1)(\mu-n\bar{x}/(n+1))^2 + {n^2\bar{x}^2 \over n+1} - \bar{x}^2n \end{align}

At this point I get stuck since ${n^2\bar{x}^2 \over n+1} - \bar{x}^2n$ don't cancel out. Plus, they cannot be ignored since we divide that by $2\sigma^2$.

$\endgroup$
1
$\begingroup$

Apologies, you are correct, this is indeed a typo from hasty cut & paste.... It was pointed out on X validated a few years ago and I presented a corrected version there.

$\endgroup$
  • 1
    $\begingroup$ Hi Prof. Robert. I was not aware of the older post that addressed this problem. Thank you. $\endgroup$ – MoneyBall Mar 2 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.