Normal linear model maximum-likelihood sampling distributions (source code)

= Normal linear model maximum-likelihood sampling distributions
{title2=$\widehat\beta\sim N_p(\beta,\sigma^2(X^TX)^{-1}),\quad n\widehat\sigma^2/\sigma^2\sim\chi^2_{n-p}$}

For a full-column-rank design $X$ and $Y=X\beta+\varepsilon$ with $\varepsilon\sim N_n(0,\sigma^2I)$, the maximum-likelihood estimators are $\widehat\beta=(X^TX)^{-1}X^TY$ and $\widehat\sigma^2=\|Y-X\widehat\beta\|^2/n$. Orthogonal Gaussian projections give their displayed distributions and independence. The <variance> maximum-likelihood estimator has expectation $(n-p)\sigma^2/n$; the unbiased residual <variance> divides by $n-p$ instead.