Pedigree

The pedigree used during the lecture corresponds to

suppressPackageStartupMessages( library(pedigreemm) )
n_nr_ani_ped <- 5
n_nr_parent <- 3
tbl_ped_simple <- dplyr::data_frame(Calf = c(1:n_nr_ani_ped),
                             Sire = c(NA, NA, NA, 1, 3),
                             Dam  = c(NA, NA, NA, 2, 2))
### # pedigreemm
(ped_simple <- pedigree(sire = tbl_ped_simple$Sire, dam = tbl_ped_simple$Dam, label = as.character(1:n_nr_ani_ped)))

Numerator Relationship Matrix

(matA_simple <- as.matrix(getA(ped = ped_simple)))
    1   2   3    4    5
1 1.0 0.0 0.0 0.50 0.00
2 0.0 1.0 0.0 0.50 0.50
3 0.0 0.0 1.0 0.00 0.50
4 0.5 0.5 0.0 1.00 0.25
5 0.0 0.5 0.5 0.25 1.00

Matrices L and D

(matD <- diag(Dmat(ped = ped_simple), n_nr_ani_ped))
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    0    0  0.0  0.0
[2,]    0    1    0  0.0  0.0
[3,]    0    0    1  0.0  0.0
[4,]    0    0    0  0.5  0.0
[5,]    0    0    0  0.0  0.5
### # get diagonal matrix S with diagonal elements being sqrt of elements of matD
matS <- sqrt(matD)
### # LDL decomposition based on cholesky
matR <- t(chol(matA_simple));matR
    1   2   3         4         5
1 1.0 0.0 0.0 0.0000000 0.0000000
2 0.0 1.0 0.0 0.0000000 0.0000000
3 0.0 0.0 1.0 0.0000000 0.0000000
4 0.5 0.5 0.0 0.7071068 0.0000000
5 0.0 0.5 0.5 0.0000000 0.7071068
(matL <- matR %*% solve(matS))
  [,1] [,2] [,3] [,4] [,5]
1  1.0  0.0  0.0    0    0
2  0.0  1.0  0.0    0    0
3  0.0  0.0  1.0    0    0
4  0.5  0.5  0.0    1    0
5  0.0  0.5  0.5    0    1

Verify

(matA_verify <- matL %*% matD %*% t(matL))
    1   2   3    4    5
1 1.0 0.0 0.0 0.50 0.00
2 0.0 1.0 0.0 0.50 0.50
3 0.0 0.0 1.0 0.00 0.50
4 0.5 0.5 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