# Marginal Posterior distribution with Normal observations

According to chapter 3 of Gelman's Data Bayesian Analysis[DBA], when we have $y_i\sim N(\mu,\sigma^2)$, and $p(\mu,\sigma^2)\propto (\sigma^2)^{-1}$

Then, $p(\mu,\sigma^2|\mathbf{y})\propto \sigma^{-n-2} exp\left( -\frac{1}{2\sigma^2}(n-1)s^2+n(\bar y -\mu)^2\right)$.

We are interested in $p(\mu|y)=\int p(\mu,\sigma^2|\mathbf{y}) \ d\sigma^2$, and Gelman states the following in page 66 of the third edition of DBA:

My doubt is on the first line of the proportionals. How do we obtain that expression? I've tried a simple multivariate version of change of variables, with $H(A,z)=(\mu,\sigma^2)$.

However, since $\frac{\partial\mu}{\partial A} = \frac{1}{2}\left( nA-n(n-1)s^2\right)^{-1/2}$, absolute value of the Jacobian(det. of der.) seems to be $\frac{A}{4z^2} \left( nA-n(n-1)s^2\right)^{-1/2}$, which doesn't seem to produce the desired expression.

Any help would be appreciated.

The posterior density is denoted by $p(\mu, \sigma^2|y)$, but you need to find the marginal posterior density for $p(\mu|y)$. This is just like the problem of obtaining a marginal density when you know the joint density. Thus,
$$p(\mu|\mathbf{y}) = \int p(\mu, \sigma^2 |\mathbf{y}) \, d \sigma^2.$$
Remember that the integral is only in $\sigma^2$ and $\mu$. So the change of variable only affects $\sigma^2$.
Let $A = (n-1)s^2 + n(\mu - \bar{y})^2$, and $z = \frac{A}{2\sigma^2}$. Then $dz = -\dfrac{A}{2(\sigma^2)^2} d\sigma^2 \implies d\sigma^2 = -\dfrac{A}{2z^2} dz$