Restricted likelihood from orthogonal error contrasts (source code)

= Restricted likelihood from orthogonal error contrasts
{title2=$\ell_R$}

For $Y\sim N(X\beta,V_\theta)$ and a full-column-rank <design matrix> $X\in\mathbb R^{n\times p}$, take $A\in\mathbb R^{n\times(n-p)}$ with $A^TA=I$ and $A^TX=0$. Then $A^TY\sim N(0,A^TV_\theta A)$, so <restricted maximum likelihood> maximizes
$$
\ell_R(\theta)=-\frac{n-p}{2}\log(2\pi)-\frac12\log\det(A^TV_\theta A)-\frac12Y^TA(A^TV_\theta A)^{-1}A^TY.
$$
Changing the <orthonormal basis> by an orthogonal matrix leaves this expression unchanged.