 </li>
  <li>
    <p>$y^TPy$ can also be calculated as $ (y-X\hat{\beta})^TV^{-1}(y-X\hat{\beta}) \ $ where $\hat{\beta}$ is estimated as usual, i.e. 
$\hat{\beta} = \left(X^TV^{-1}X\right)^{-1}X^TV^{-1}y$</p>
  </li>
</ul>

<p>Therefore we obtain the following expression for the REML log-likelihood:</p>

<script type="math/tex; mode=display">
-\frac12 (N-D)\log(2\pi) - \frac{C}{2} + \frac12\log\left|X^TX\right| - \frac12 \log|V| -\frac12\log\left|X^TV^{-1}X\right| - \frac12 (y-X\hat{\beta})^TV^{-1}(y-X\hat