Normal regression with independent coefficient and variance priors (source code)

= Normal regression with independent coefficient and variance priors
{title2=$b\sim N(b_0,D),\quad s\sim\operatorname{InvGamma}(a_0,c_0),\quad b\perp s$}

In a <normal linear model> $Y\mid b,s\sim N(Xb,sI)$, assign the coefficient <vector> $b$ a proper <normal distribution> with fixed positive-definite <covariance matrix> $D$, independently of the <variance> $s$, whose <prior distribution> is <inverse-gamma distribution>. <Completing the square> gives
$$
V(s)=(D^{-1}+X^TX/s)^{-1},\qquad
m(s)=V(s)(D^{-1}b_0+X^Ty/s),\qquad
b\mid s,y\sim N(m(s),V(s)).
$$
Multiplying the residual <likelihood function> by the <inverse-gamma distribution> density also gives
$$
s\mid b,y\sim\operatorname{InvGamma}\left(a_0+n/2,c_0+\lVert y-Xb\rVert^2/2\right).
$$
These <full conditional distributions> permit a <Gibbs sampler>. The marginal coefficient <posterior distribution> is obtained by <marginalization> over $s$. Its conditional <mean> and <covariance matrix> both depend on $s$, so it is generally not a <Student's t-distribution>. Even if the columns of $X$ and the prior coordinates make the conditional coefficient components independent, averaging over a shared unknown $s$ need not preserve that <independence>.

A <normal-inverse-gamma prior> instead scales the conditional coefficient prior <covariance matrix> by $s$, producing a multivariate <Student's t-distribution> on <marginalization>. It is a different joint <prior distribution>.