torch_openreml.loglik¶
- torch_openreml.loglik(y, x, v)[source]¶
Evaluate the REML log-likelihood.
\[\ell_R = -\frac{1}{2} \left( \log |\symbf{V}| + \log |\symbf{X}^\top \symbf{V}^{-1} \symbf{X}| + \symbf{y}^\top \symbf{P} \symbf{y} \right)\]where \(\symbf{P} = \symbf{V}^{-1} - \symbf{V}^{-1}\symbf{X} (\symbf{X}^\top\symbf{V}^{-1}\symbf{X})^{-1}\symbf{X}^\top\symbf{V}^{-1}\) is the projection matrix. The quadratic \(\symbf{y}^\top \symbf{P} \symbf{y}\) is evaluated as \(\hat{\symbf{e}}^\top \symbf{V}^{-1} \hat{\symbf{e}}\), with \(\hat{\symbf{e}}\) the marginal residuals.
- Parameters:
y (torch.Tensor) – Response vector of shape
(n,).x (torch.Tensor) – Fixed-effect design matrix of shape
(n, p).v (torch.Tensor) – Marginal covariance matrix of shape
(n, n), e.g. \(\symbf{V}(\boldsymbol{\theta})\) evaluated at fitted covariance parameters.
- Returns:
Scalar REML log-likelihood value.
- Return type:
torch.Tensor