Solution (source code)

= Solution

Let $\mathrm{RSS}=\|Y-X\widehat\theta\|^2$. The usual unbiased error-<variance> estimator is
$$
\boxed{s^2=\frac{\mathrm{RSS}}{n-p}.}
$$
Indeed the residual is the <orthogonal projection> of $\epsilon$ onto the $(n-p)$-dimensional complement of the design column space, giving $\mathrm{RSS}/\sigma^2\sim\chi^2_{n-p}$ and expected RSS equal to $(n-p)\sigma^2$. The <maximum-likelihood estimator> instead divides RSS by $n$; the unbiased divisor above is the one used for the exact t-interval in part (d).