getSparseInv | R Documentation |
Efficiently computes the entries of the sparse inverse (C) of a square, symmetric matrix (W) from its square-root-free Cholesky decomposition (W = L D L') as implemented in LDLT
.
This is notably used in quantitative genetics as described initially by Misztal and Perez-Enciso (1993).
See the section 15.7 "Computing entries of the inverse of a sparse matrix" from Duff et al (2017) for the correct equation.
getSparseInv(vecD, L, reprSparse = NULL, verbose = FALSE)
vecD |
vector |
L |
lower triangular matrix |
reprSparse |
if not NULL, the output matrix will be a |
verbose |
verbosity level |
matrix
Timothee Flutre
LDLT
## Not run: ## example matrix from Misztal and Perez-Enciso (1993):
W <- matrix(NA, nrow=5, ncol=5)
W[1,] <- c(5, 0, 0, 3, 0)
W[2,-1] <- c(3, 0, 0, 1)
W[3,-c(1:2)] <- c(4, 1, 1)
W[4,-c(1:3)] <- c(4, 0)
W[5,-c(1:4)] <- 2
W
W[lower.tri(W)] <- t(W)[lower.tri(W)]
W
## LDLT decomposition (a.k.a. square-root-free Cholesky):
decomp <- LDLT(W, returnFormat="list")
## C, inverse of W:
getSparseInv(decomp$vecD, decomp$L)
getSparseInv(decomp$vecD, decomp$L, "T")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.