####=========================================####
#### 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_gryphon)
# DT <- DT_gryphon
# A <- A_gryphon
# P <- P_gryphon
# #### look at the data
# head(DT)
# #### fit the model with no fixed effects (intercept only)
# mix1 <- mmes(BWT~1,
# random=~vsm(ism(ANIMAL),Gu=A),
# rcov=~units,
# data=DT)
# summary(mix1)$varcomp
#
# ## mmes algorithm uses the inverse of the relationship matrix
# ## if you select henderson=TRUE
# Ai <- solve(A + diag(1e-4,ncol(A),ncol(A)))
# Ai <- as(as(as( Ai, "dMatrix"), "generalMatrix"), "CsparseMatrix")
# attr(Ai, 'inverse')=TRUE
# ####====================####
# #### multivariate model ####
# #### 2 traits ####
# ####====================####
# head(DT)
#
# traits <- c("BWT","TARSUS")
# DT[,traits] <- apply(DT[,traits],2,scale)
# DTL <- reshape(DT[,c("ANIMAL","MOTHER","BYEAR","SEX", traits)],
# idvar = c("ANIMAL","MOTHER","BYEAR","SEX"),
# varying = traits,
# v.names = "value", direction = "long",
# timevar = "trait", times = traits )
# DTL <- DTL[with(DTL, order(trait,ANIMAL)), ]
# head(DTL)
#
# # #### fit the multivariate model with no fixed effects (intercept only)
# mix2 <- mmes(value~trait, # henderson=TRUE,
# random=~vsm(usm(trait),ism(ANIMAL),Gu=A),
# rcov=~vsm(dsm(trait),ism(units)),
# data=DTL)
# summary(mix2)$varcomp
# cov2cor(mix2$theta[[1]])
Run the code above in your browser using DataLab