torch_openreml.post.cov_blup

torch_openreml.post.cov_blup(x, z, g, v)[source]

Compute the covariance matrix of the BLUPs.

\[\operatorname{Var}(\hat{\symbf{b}}) = \symbf{G}\symbf{Z}^\top\symbf{P}\symbf{Z}\symbf{G}, \qquad \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}.\]

Unlike the equivalent block form \(\symbf{G} - \symbf{C}_{22}\), this expression only requires \(\symbf{V}\) to be invertible, not \(\symbf{G}\).

Parameters:
  • x (torch.Tensor) – Fixed-effect design matrix of shape (n, p).

  • z (torch.Tensor) – Random-effect design matrix of shape (n, q).

  • g (torch.Tensor) – Random-effect covariance matrix of shape (q, q), e.g. \(\symbf{G}(\boldsymbol{\theta})\) evaluated at fitted covariance parameters.

  • v (torch.Tensor) – Marginal covariance matrix of shape (n, n), e.g. \(\symbf{V}(\boldsymbol{\theta})\) evaluated at fitted covariance parameters.

Returns:

BLUP covariance matrix of shape (q, q).

Return type:

torch.Tensor