# Posterior distribution of linear regression with normal and inverse gamma prior

If I have the following model:

$$y\sim N_n(X\beta, \sigma^2 I_n)$$ with prior distributions:

$$\beta\sim N_n(\beta_0, B_0)$$ and $$\sigma^2 \sim IG(\alpha_0/ 2, \delta_0/2)$$

What would be the posterior of $\theta=(\beta,\sigma^2)$?

The joint posterior is a Normal-Inverse Gamma, with parameters $(\mu_n, B_n, \alpha_n, \beta_n)$ where:
$$B_n = \frac{1}{B_{0}^{-1} + n}$$ $$\mu_n = B_n(B_0^{-1}\mu_0 + n\bar{x})$$ $$\alpha_n = \alpha_0 + \frac{n}{2}$$ $$\beta_n = \beta_0 + \frac{1}{2}[\mu_0^{2}B_0^{-1} + \sum_{i}x_{i}^{2} - \mu^{2}_nB_n^{-1}]$$
Deriving these parameters can be beastly (see here for more details). Usually people solve for the full conditionals of $\beta$ and $\sigma^{2}$ (they each take a more manageable closed form distribution) and use Gibbs sampling to find the posterior for each parameter.
• Thanks for your answer. What about if I change the prior of $\beta$ to be a multivariate t distribution $t_nu(\beta_0, B_0)$ Dec 15, 2015 at 4:05
• I think that‘s not correct. The above question does not assume that $\beta$ depends on $\sigma$. Your answer only works for $\beta\sim N_n(\beta_0, \sigma B_0)$. Jun 25, 2020 at 21:10