Solution (source code)

= Solution

After integrating out the <multivariate normal distribution> $\beta$, the <marginal distribution> is
$$
Y\sim N\!\left(0,\sigma^2A\right),
\qquad A=XX^T+\alpha I_n.
$$
Up to terms independent of $\sigma^2$, the <log-likelihood> is
$$
\ell(\sigma^2)=-\frac n2\log\sigma^2
-\frac1{2\sigma^2}Y^TA^{-1}Y.
$$
Differentiating and setting the result to zero gives the <maximum marginal likelihood estimator>
$$
\widehat{\sigma}^2=\frac1nY^T(XX^T+\alpha I_n)^{-1}Y.
$$
This is an <Empirical Bayes method> because the estimated <hyperparameter> is then inserted into the prior and posterior distributions.