data(DT_example)
DT <- DT_example
DT=DT[with(DT, order(Env)), ]
A <- A_example
# if using mmes=TRUE remember to provide relationship as inverse in the Gu argument
# Ai <- solve(A + diag(1e-4,ncol(A),ncol(A)))
# Ai <- as(as(as( Ai, "dMatrix"), "generalMatrix"), "CsparseMatrix")
x <- as.character(unique(DT$Name))
DT <- droplevels(DT[which(!is.na(match(DT$Name, x[1:5]))),])
## ============================ ##
## example without structure
## ============================ ##
ism(DT$Name)
mix <- mmes(Yield~Env,
random= ~ vsm(ism(Name)),
rcov=~ units,
nIters=10,
data=DT)
## ============================ ##
## example to without structure but
## using covariance among levels in the
## random effect Name
## ============================ ##
mix <- mmes(Yield~Env,
random= ~ vsm(ism(Name), Gu=A),
rcov=~ units,
nIters=10,
data=DT)
summary(mix)$varcomp
## ============================ ##
## example to use dsm() structure (DIAGONAL)
## ============================ ##
dsm(DT$Year)
mix <- mmes(Yield~Env,
random= ~ vsm(dsm(Year),ism(Name)),
rcov=~ vsm(dsm(Year),ism(units)),
nIters=10,
data=DT)
summary(mix)$varcomp
## ============================ ##
## example to use atm() structure (level-specific)
## ============================ ##
# unique(DT$Year)
# mix <- mmes(Yield~Env,
# random= ~ vsm(atm(Year,c("2011","2012")),ism(Name)),
# rcov=~ vsm(dsm(Year),ism(units)),
# data=DT)
## ============================ ##
## example to use usm() structure (UNSTRUCTURED)
## ============================ ##
usm(DT$Year)
mix <- mmes(Yield~Env,
random= ~ vsm(usm(Year),ism(Name)),
rcov=~ vsm(dsm(Year),ism(units)),
nIters = 10,
data=DT)
## ============================ ##
## example using structure in fixed effect
## (notice the isFixed argument)
## ============================ ##
mix <- mmes(Yield~ vsm(atm(Env,"CA.2011"), ism(Name), isFixed = TRUE),
rcov=~ units,
nIters=10,
data=DT)
Run the code above in your browser using DataLab