Tinv <- makeTinv(Mrode2)
# Method for a numeric pedigree (of `nadiv` class "numPed")
nPed <- numPed(Mrode2)
Tinv2 <- makeTinv(nPed)
########
DF <- makeDiiF(Mrode2)
# manually construct the inverse of the relatedness matrix `Ainv`
Dinv <- DF$D #<-- not the inverse yet, just copying the object
Dinv@x <- 1 / DF$D@x #<-- inverse of a diagonal matrix
handAinv <- crossprod(Tinv, Dinv) %*% Tinv
# make the A-inverse directly
Ainv <- makeAinv(Mrode2)$Ainv
# Compare
handAinv
Ainv
stopifnot(all(abs((Ainv - handAinv)@x) < 1e-6))
Run the code above in your browser using DataLab