####=========================================####
#### 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_technow)
DT <- DT_technow
Md <- Md_technow
Mf <- Mf_technow
# Md <- (Md*2) - 1
# Mf <- (Mf*2) - 1
# Ad <- A.mat(Md)
# Af <- A.mat(Mf)
# ###=========================================####
# ###=========================================####
# ans2 <- mmes(GY~1,
# random=~vsm(ism(dent),Gu=Ad) + vsm(ism(flint),Gu=Af),
# rcov=~units,
# data=DT)
# summary(ans2)$varcomp
#
# Adi <- solve(Ad + diag(1e-4,ncol(Ad),ncol(Ad)))
# Adi <- as(as(as( Adi, "dMatrix"), "generalMatrix"), "CsparseMatrix")
# attr(Adi, 'inverse')=TRUE
# Afi <- solve(Af + diag(1e-4,ncol(Af),ncol(Af)))
# Afi <- as(as(as( Afi, "dMatrix"), "generalMatrix"), "CsparseMatrix")
# attr(Afi, 'inverse')=TRUE
# ####====================####
# #### multivariate model ####
# #### 2 traits ####
# ####====================####
# head(DT)
#
# traits <- c("GY","GM")
# DT[,traits] <- apply(DT[,traits],2,scale)
# DTL <- reshape(DT[,c("hybrid","dent","flint", traits)],
# idvar = c("hybrid","dent","flint"),
# varying = traits,
# v.names = "value", direction = "long",
# timevar = "trait", times = traits )
# DTL <- DTL[with(DTL, order(trait,hybrid)), ]
# head(DTL)
#
# M <- rbind(Md,Mf)
# A <- A.mat(M)
# Ai <- solve(A + diag(1e-4,ncol(A),ncol(A)))
# Ai <- as(as(as( Ai, "dMatrix"), "generalMatrix"), "CsparseMatrix")
# attr(Ai, 'inverse')=TRUE
#
# ans3 <- mmes(value~trait, henderson=TRUE,
# random=~vsm(usm(trait),ism(overlay(dent,flint)),Gu=Ai),
# rcov=~ vsm(dsm(trait), ism(units)),
# data=DTL)
# summary(ans3)
# cov2cor(ans3$theta[[1]])
Run the code above in your browser using DataLab