0
$\begingroup$

I'm struggling to follow a specific step in the proof that

$$ \tau \sim \text{Gamma}(\alpha, \beta), \quad \mu | \tau \sim \mathcal{N}(\nu, \frac{1}{k\tau}) $$

is a conjugate prior distribution for a sample of iidrvs with distribution $\mathcal{N}(\mu, \frac{1}{\tau})$.

I'm able to derive that the posterior distribution is

$$ \pi(\tau, \mu|\mathbf{x}) \propto \tau ^{\alpha + \frac{n}{2} - \frac{1}{2}}\text{exp}\Big(-\tau \Big[\beta + \frac{k}{2}(\mu - \nu)^2 + \frac{1}{2}\sum(x_i-\mu)^2\Big]\Big) $$

After that, my book (and all other references I could find) just says:

Complete the square to see that $$ k(\mu-\nu)^2 + \sum(x_i - \mu)^2 $$ $$=(k + n)\Big(\mu-\frac{k\nu + n\bar{x}}{k + n}\Big)^2 + \frac{nk}{n+k}(\bar{x} - \nu)^2 + \sum(x_i - \bar{x})^2 $$

I don't see how this follows without doing (what seems like) an unreasonable amount of algebra. I get the sense there must be some neat way of doing this that I'm not spotting.

Any help would be much appreciated. Thank you.

$\endgroup$
1
  • 1
    $\begingroup$ Several answers already on site demonstrate "completing the square" in respect of similar Bayesian problems. It would be worthwhile taking a look at some of them $\endgroup$
    – Glen_b
    Feb 19, 2020 at 4:48

1 Answer 1

0
$\begingroup$

$$ \pi(\tau, \mu|\mathbf{x}) \propto \tau ^{\alpha + \frac{n}{2} - \frac{1}{2}}\text{exp}\Big(-\tau \Big[\beta + \frac{k}{2}(\mu - \nu)^2 + \frac{1}{2}\sum(x_i-\mu)^2\Big]\Big) $$

$$ \pi(\tau, \mu|\mathbf{x}) \propto \tau ^{\alpha + \frac{n}{2} - \frac{1}{2}}\text{exp}\Big(-\tau \Big[\beta + \frac{1}{2}(k + n)\Big(\mu-\frac{k\nu + n\bar{x}}{k + n}\Big)^2 +\frac{1}{2} \frac{nk}{n+k}(\bar{x} - \nu)^2 + \frac{1}{2}\sum(x_i - \bar{x})^2\Big]\Big) $$

define

$$A=\frac{1}{2} \frac{nk}{n+k}(\bar{x} - \nu)^2 + \frac{1}{2}\sum(x_i - \bar{x})^2$$

$$ \pi(\tau, \mu|\mathbf{x}) \propto \tau ^{\alpha + \frac{n}{2} - \frac{1}{2}}\text{exp}\Big(-\tau \Big[\beta+A + \frac{1}{2}(k + n)\Big(\mu-\frac{k\nu + n\bar{x}}{k + n}\Big)^2 \Big]\Big) $$

for $\tau$

$$ \pi(\tau|\mathbf{x}) \propto \int \tau ^{\alpha + \frac{n}{2} - \frac{1}{2}}\text{exp}\Big(-\tau \Big[\beta+A + \frac{1}{2}(k + n)\Big(\mu-\frac{k\nu + n\bar{x}}{k + n}\Big)^2 \Big]\Big) d\mu $$

$$ \pi(\tau|\mathbf{x}) \propto \tau^{\alpha + \frac{n}{2} - \frac{1}{2}}e^{-\tau (\beta+A) }\int e^{ -\frac{\tau}{2}(k + n)\Big(\mu-\frac{k\nu + n\bar{x}}{k + n}\Big)^2 } d\mu $$

$$ \pi(\tau|\mathbf{x}) \propto \tau^{\alpha + \frac{n}{2} - \frac{1}{2}}e^{-\tau (\beta+A) }\int e^{ -\frac{\tau}{2}(k + n)\Big(\mu-\frac{k\nu + n\bar{x}}{k + n}\Big)^2 } d\mu \frac{\sqrt{\frac{1}{\tau(k + n)}}}{\sqrt{\frac{1}{\tau(k + n)}}} $$

$$ \pi(\tau|\mathbf{x}) \propto \tau^{\alpha + \frac{n}{2} - \frac{1}{2}}e^{-\tau (\beta+A) } \sqrt{\frac{1}{\tau(k + n)}}\int \frac{1}{\sqrt{\frac{1}{\tau(k + n)}}} e^{ -\frac{\tau}{2}(k + n)\Big(\mu-\frac{k\nu + n\bar{x}}{k + n}\Big)^2 } d\mu $$

do you see that integral $\propto 1$??(normal distribution).

$$ \pi(\tau, \mu|\mathbf{x}) \propto \tau ^{\alpha + \frac{n}{2} - \frac{1}{2}}\text{exp}\Big(-\tau \Big[\beta + \frac{1}{2}(k + n)\Big(\mu-\frac{k\nu + n\bar{x}}{k + n}\Big)^2 +\frac{1}{2} \frac{nk}{n+k}(\bar{x} - \nu)^2 + \frac{1}{2}\sum(x_i - \bar{x})^2\Big]\Big) $$

$$ \pi( \mu|\tau,\mathbf{x}) \propto \text{exp}\Big(-\tau \Big[ \frac{1}{2}(k + n)\Big(\mu-\frac{k\nu + n\bar{x}}{k + n}\Big)^2 \Big]\Big) $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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