I would like to infer the regression coefficients and the noise precision of a standard linear regression problem defined by
$$ y=X\theta + \epsilon, $$
where $X$ is a $n\times p$ design matrix, $\theta$ is a length $p$ vector of regression coefficients, $y$ is a length $n$ vector of observations of the dependent variable, and $\epsilon$ is a length $n$ vector of independent, zero-mean Gaussian noise with precision $\tau$.
Choosing a joint conjugate prior on the regression coefficients and the noise precision, the posterior distribution is multivariate-normal-gamma with posterior hyperparameters (see wikipedia for details)
\begin{align} \Lambda_n&=X'X + \Lambda_0\\ \mu_n&=\Lambda_n^{-1}\left(\Lambda_0\mu_0 + X^Ty\right)\\ a_n&=a_0 + \frac n2\\ b_n&=b_0 + \frac 12\left(y^Ty + \mu_0\Lambda_0\mu_0 - \mu_n\Lambda_n\mu_n\right), \end{align}
where $\Lambda$, $\mu$ denote the precision matrix and mean for $\theta$, and $a$, $b$ denote the shape and scale for $\tau$. Zero subscripts denote prior hyperparameters and $n$ subscripts denote posterior hyperparameters.
Whenever $n\gg p$m the inference works well. But when $n\gtrsim p$, the inference for the precision parameter fails and the support of the posterior is at larger values than the true value. E.g. for $n=500$ and $p=100$, I get the following results. Do you have any idea why?
The code is here.