# ####=========================================####
# #### For CRAN time limitations most lines in the
# #### examples are silenced with one '#' mark,
# #### remove them and run the examples using
# #### command + shift + C |OR| control + shift + C
# ####=========================================####
#
# data(DT_cornhybrids)
# DT <- DT_cornhybrids
# DTi <- DTi_cornhybrids
# GT <- GT_cornhybrids
# hybrid2 <- DT # extract cross data
# A <- GT
# K1 <- A[levels(hybrid2$GCA1), levels(hybrid2$GCA1)]; dim(K1)
# K2 <- A[levels(hybrid2$GCA2), levels(hybrid2$GCA2)]; dim(K2)
# S <- kronecker(K1, K2) ; dim(S)
# rownames(S) <- colnames(S) <- levels(hybrid2$SCA)
#
# ans <- mmes(Yield ~ Location,
# random = ~ vsm(ism(GCA1),Gu=K1) + vsm(ism(GCA2),Gu=K2), # + vsm(ism(SCA),Gu=S),
# rcov=~units,
# data=hybrid2)
# summary(ans)$varcomp
#
# ## mmec uses the inverse of the relationship matrix
# K1i <- solve(K1 + diag(1e-4,ncol(K1),ncol(K1)))
# K1i <- as(as(as( K1i, "dMatrix"), "generalMatrix"), "CsparseMatrix")
# K2i <- solve(K2 + diag(1e-4,ncol(K2),ncol(K2)))
# K2i <- as(as(as( K2i, "dMatrix"), "generalMatrix"), "CsparseMatrix")
# Si <- solve(S + diag(1e-4,ncol(S),ncol(S)))
# Si <- as(as(as( Si, "dMatrix"), "generalMatrix"), "CsparseMatrix")
# ans2 <- mmes(Yield ~ Location,
# random = ~ vsm(ism(GCA1),Gu=K1i) + vsm(ism(GCA2),Gu=K2i), # + vsm(ism(SCA),Gu=Si),
# henderson=TRUE,
# rcov=~units,
# data=hybrid2)
# summary(ans2)$varcomp
Run the code above in your browser using DataLab