s_data_url <- "https://charlotte-ngs.github.io/lbgfs2021/data/beef_data_blup.csv"

Read the data into R

tbl_data_beef <- readr::read_csv(file = s_data_url)
tbl_data_beef

Mixed Linear Effect Model

Animal model

$$y = X\beta + Zu + e$$

Observations

vec_y <- tbl_data_beef$`Weaning Weight`
vec_y

Design Matrices

mat_X <- matrix(data = c(1, 0,
                         1, 0,
                         1, 0,
                         1, 0,
                         0, 1,
                         0, 1,
                         0, 1,
                         0, 1,
                         1, 0,
                         1, 0,
                         1, 0,
                         1, 0,
                         0, 1,
                         0, 1,
                         0, 1,
                         0, 1), ncol = 2, byrow = TRUE)
mat_X
tbl_data_beef$Herd
mat_Z <- matrix(data = c(), ncol=27, byrow = TRUE)
mat_Z

Inverse Numerator Relationship Matrix

ped <- pedigreemm::pedigree(sire = c(),
                            dam = c(),
                            label = as.character(1:27))
Ainv <- as.matrix(pedigreemm::getAInv(ped = ped))

Solving MME

lambda <- 1
mat_xtx <- t(mat_X) %*% mat_X
mat_xtx
mat_xtx <- crossprod(mat_X)
mat_xtx
mat_xtz <- crossprod(mat_X,mat_Z)
mat_xtz
mat_ztx <- crossprod(mat_Z,mat_X)
mat_ztx <- t(mat_xtz)
mat_ztx
mat_ztz <- crossprod(mat_Z)
mat_ztz

Solutions for Fixed Effecs and Breeding Values



charlotte-ngs/lbgfs2021 documentation built on Dec. 19, 2021, 3:01 p.m.