LDLT | R Documentation |
This wrapper around chol
factors a square, symmetric, positive (semi-)definite matrix into the product of a lower triangular matrix (L), a diagonal matrix (D), and an upper triangular matrix (U) equal to the transpose of the lower triangular one (U=L').
It is also known as the square-root-free Cholesky decomposition.
This decomposition is notably used in quantitative genetics (Misztal and Perez-Enciso, 1993).
The determinant of the input matrix is then easily computed as the product of the diagonal entries of the decomposition.
LDLT(x, returnFormat = "matrix")
x |
matrix |
returnFormat |
a lower triangular matrix with the elements of D on the diagonal, or a list with two components, L as a matrix with 1 on the diagonal and the diagonal of D as a vector |
matrix
getSparseInv
## 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
## decomposition/factorization:
(decompM <- LDLT(W, returnFormat="matrix"))
(decompL <- LDLT(W, returnFormat="list"))
## determinant:
prod(diag(decompM)) # ~= 162, as in the paper
prod(decompL$vecD)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.