# relfactorInv: Inverse relationship factor from a pedigree In pedigreeTools: Versatile Functions for Working with Pedigrees

 relfactorInv R Documentation

## Inverse relationship factor from a pedigree

### Description

Get inverse of the left Cholesky factor of the relationship matrix for the pedigree `ped`.

### Usage

``````relfactorInv(ped)

getLInv(ped)
``````

### Arguments

 `ped` `pedigree`

### Details

Note that the inverse of the left Cholesky factor is returned, which is lower triangular, that is from A = LL' (lower inv(A) = inv(LL') = inv(L)' inv(L) (upper triangular).

### Value

matrix (dtCMatrix - triangular sparse)

### Functions

• `getLInv()`: Inverse relationship factor from a pedigree

### Examples

``````ped <- pedigree(sire = c(NA, NA, 1,  1, 4, 5),
dam =  c(NA, NA, 2, NA, 3, 2),
label = 1:6)
(LInv <- getLInv(ped))
solve(Matrix::t(getL(ped)))

# Test for correctness
LInvExp <- matrix(data = c( 1.0000,  0.0000,  0.0000,  0.0000,  0.0000, 0.0000,
0.0000,  1.0000,  0.0000,  0.0000,  0.0000, 0.0000,
-0.7071, -0.7071,  1.4142,  0.0000,  0.0000, 0.0000,
-0.5774,  0.0000,  0.0000,  1.1547,  0.0000, 0.0000,
0.0000,  0.0000, -0.7071, -0.7071,  1.4142, 0.0000,
0.0000, -0.7303,  0.0000,  0.0000, -0.7303, 1.4606),
byrow = TRUE, nrow = 6)
stopifnot(!any(abs(round(LInv, digits = 4) - LInvExp) > .Machine\$double.eps))
L <- t(chol(getA(ped)))
LInvExp <- solve(L)
stopifnot(!any(abs(LInv - LInvExp) > .Machine\$double.eps))
stopifnot(is(LInv, "sparseMatrix"))
``````

pedigreeTools documentation built on Aug. 15, 2023, 9:07 a.m.