data(DT_example)
DT <- DT_example
DT=DT[with(DT, order(Env)), ]
A <- A_example
x <- as.character(unique(DT$Name))
DT <- droplevels(DT[which(!is.na(match(DT$Name, x[1:5]))),])
## ============================ ##
## example without structure
## ============================ ##
isc(DT$Name)
mix <- mmec(Yield~Env,
random= ~ vsc(isc(Name)),
rcov=~ units,
nIters=3,
data=DT)
## ============================ ##
## example to without structure but
## using covariance among levels in the
## random effect Name
## ============================ ##
Ai <- as(solve(A + diag(1e-4,ncol(A),ncol(A))), Class="dgCMatrix")
mix <- mmec(Yield~Env,
random= ~ vsc(isc(Name), Gu=Ai),
rcov=~ units,
nIters=3,
data=DT)
summary(mix)$varcomp
## ============================ ##
## example to use dsc() structure (DIAGONAL)
## ============================ ##
dsc(DT$Year)
mix <- mmec(Yield~Env,
random= ~ vsc(dsc(Year),isc(Name)),
rcov=~ vsc(dsc(Year),isc(units)),
nIters=3,
data=DT)
summary(mix)$varcomp
## ============================ ##
## example to use atc() structure (level-specific)
## ============================ ##
# unique(DT$Year)
# mix <- mmec(Yield~Env,
# random= ~ vsc(atc(Year,c("2011","2012")),isc(Name)),
# rcov=~ vsc(dsc(Year),isc(units)),
# data=DT)
## ============================ ##
## example to use usc() structure (UNSTRUCTURED)
## ============================ ##
usc(DT$Year)
mix <- mmec(Yield~Env,
random= ~ vsc(usc(Year),isc(Name)),
rcov=~ vsc(dsc(Year),isc(units)),
nIters = 3,
data=DT)
## ============================ ##
## example using structure in fixed effect
## (notice the isFixed argument)
## ============================ ##
mix <- mmec(Yield~ vsc(atc(Env,"CA.2011"), isc(Name), isFixed = TRUE),
rcov=~ units,
nIters=3,
data=DT)
Run the code above in your browser using DataLab