relfactor | R Documentation |
Determine the right Cholesky factor of the relationship matrix
for the pedigree ped
, possibly restricted to the specific labels
that occur in labs
.
relfactor(ped, labs = NULL)
getL(ped, labs = NULL)
ped |
|
labs |
a character vector or a factor giving individual labels to
which to restrict the relationship matrix and corresponding factor using
Colleau et al. (2002) algorithm. If |
Note that the right Cholesky factor is returned, which is upper triangular, that is from A = LL' = R'R (lower (upper triangular) and not L (lower triangular) as the function name might suggest.
matrix (dtCMatrix
- upper triangular sparse)
getL()
: Relationship factor from a pedigree
Colleau, J.-J. An indirect approach to the extensive calculation of relationship coefficients. Genet Sel Evol 34, 409 (2002). https://doi.org/10.1186/1297-9686-34-4-409
ped <- pedigree(sire = c(NA, NA, 1, 1, 4, 5),
dam = c(NA, NA, 2, NA, 3, 2),
label = 1:6)
(L <- getL(ped))
chol(getA(ped))
# Test for correctness
LExp <- matrix(data = c(1.0000, 0.0000, 0.5000, 0.5000, 0.5000, 0.2500,
0.0000, 1.0000, 0.5000, 0.0000, 0.2500, 0.6250,
0.0000, 0.0000, 0.7071, 0.0000, 0.3536, 0.1768,
0.0000, 0.0000, 0.0000, 0.8660, 0.4330, 0.2165,
0.0000, 0.0000, 0.0000, 0.0000, 0.7071, 0.3536,
0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.6847),
byrow = TRUE, nrow = 6)
stopifnot(!any(abs(round(L, digits = 4) - LExp) > .Machine$double.eps))
LExp <- chol(getA(ped))
stopifnot(!any(abs(L - LExp) > .Machine$double.eps))
(L <- getL(ped, labs = 4:6))
(LExp <- chol(getA(ped)[4:6, 4:6]))
stopifnot(!any(abs(L - LExp) > .Machine$double.eps))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.