Manipulation into Gaussian (?) integral - Statistics

56 Views Asked by At

Let $\underline X$ be a sample of size $n$ from normal distribution $X \sim \mathcal{N}(\theta,\,\phi^{-1})$. First, I'm asked to show that the likelihood of the observations $x_1, x_2, ..., x_n$ is $$L(\theta,\phi) \propto \phi^{\frac{n}{2}} \cdot \exp\bigg\{-\frac{\phi}{2} \big[s^2 + n (\overline x - \theta )^2\big] \bigg\} $$ with $s^2 = {‎‎\sum}_{i=1}^{n} (x_i - \overline x)^2$, which I have shown. Then, we assign to $\phi$ a Gamma prior with parameters $p,q$, and to $\theta$ a normal prior, with mean $0$ and variance $\phi^{-1}$: $$f_{\phi}(\phi) \propto e^{-q\phi}\cdot\phi^{p-1} \text{ and } f_{\theta}(\theta) \propto \phi^{\frac{1}{2}} \cdot \exp \big\{\frac{-\theta^2 \phi}{2} \big\}$$

I am then instructed to find the joint posterior, as well as the marginals posteriors for $\theta$ and $\phi$.

The joint posterior is proportional to the product of all the PDF's I've written; $\theta$ and $\phi$ may not be independent, but writing $$f(\theta,\phi)= f_{\theta}(\theta | \phi) \cdot f_{\phi}(\phi)$$ I get the wanted result. So, using Baye's theorem $f(\theta,\phi | \underline x) \propto f(\underline x | \theta, \phi) \cdot f(\theta, \phi)$ I arrive at $$f(\theta,\phi | \underline x) \propto \phi^{p+\frac{n+1}{2}-1} \cdot \exp\bigg\{-\frac{\phi}{2}\big[s^2 + n (\overline x - \theta )^2 +2q +\theta^2\big]\bigg\}$$


I believe the above are correct. Now, onto the marginal posteriors.

The posterior of $\theta$ (which is of course with respect to $\phi$) is fairly easy to calculate (its family, at least); I just think of $p+\frac{n+1}{2}$ as $P$ and $\frac{1}{2}\big[s^2 + n (\overline x - \theta )^2 +2q +\theta^2\big]$ as $Q$, and it's easy to see that $f(\theta | \underline x) = \int_{\Phi} f(\theta,\phi | \underline x) \,d\phi$ can be manipulated with the help of Gamma distribution, giving me the final result of $f(\theta| \underline x) \propto \frac {\Gamma(p+\frac{n+1}{2})} {\bigg(\frac{1}{2}\big[s^2 + n (\overline x - \theta )^2 +2q +\theta^2\big] \bigg)^{p+\frac{n+1}{2}}}$

However, I can't seem to have any luck calculating the marginal posterior of $\phi$. I have to integrate with respect to $\theta$ this time, and since $\theta$ follows normal distribution, I'll have to integrate all over the real line. My failed attempt was the following

The process may become easier, if I try the same trick as before, to "consruct" the PDF of a distribution in the integral, so that it will give me $1$. I did it with Gamma before, so maybe normal this time.

I seperate the $\phi$'s from $\theta$'s: $f(\phi| \underline x) = \int_{\Theta} f(\theta,\phi | \underline x) \,d\theta = \phi^{{p+\frac{n+1}{2}-1}} \cdot e^{-\frac{\phi}{2}q} \cdot \exp\bigg\{-\frac{\phi}{2}\big[s^2 + n (\overline x - \theta )^2 +\theta^2\big]\bigg\}$

And now I hope that $\exp\bigg\{-\frac{\phi}{2}\big[s^2 + n (\overline x - \theta )^2 +\theta^2\big]\bigg\}$, or in other words in its original form $\exp\bigg\{-\frac{\phi}{2}\big[ \sum_{i=1}^{n}(x_i-\theta)^2 + \theta^2 \big]\bigg\}$ can be manipulated into a form that is PDF to a variable that follows normal distribution, obviously with variance $\phi^{-1}$ (I think -hence the "?" in the title- that it is called a Gaussian integral).

But I am stuck here, and can't see how this could be transformed. The extra $\theta^2$ is giving me hard times. But perhaps the approach is incorrect, and there is another trick or method to evaluate the integral, or even the PDF without doing the integration, I don't know.
Thanks in advance to anyone that takes a look, and sorry for the long text!