data(DT_example)
DT <- DT_example
A <- A_example
## ============================ ##
## example to without structure
## ============================ ##
dsr(DT$Year)
mix <- mmer(Yield~Env,
random= ~ vsr(Name),
rcov=~ vsr(units),
data=DT)
## ============================ ##
## example to without structure but
## using covariance among levels in the
## random effect Name
## ============================ ##
dsr(DT$Year)
mix <- mmer(Yield~Env,
random= ~ vsr(Name, Gu=A),
rcov=~ vsr(units),
data=DT)
## ============================ ##
## example to use dsr() structure (DIAGONAL)
## ============================ ##
dsr(DT$Year)
mix <- mmer(Yield~Env,
random= ~ vsr(dsr(Year),Name),
rcov=~ vsr(dsr(Year),units),
data=DT)
## ============================ ##
## example to use atr() structure (level-specific)
## ============================ ##
unique(DT$Year)
mix <- mmer(Yield~Env,
random= ~ vsr(atr(Year,c("2011","2012")),Name),
rcov=~ vsr(dsr(Year),units),
data=DT)
## ============================ ##
## example to use usr() structure (UNSTRUCTURED)
## ============================ ##
usr(DT$Year)
mix <- mmer(Yield~Env,
random= ~ vsr(usr(Year),Name),
rcov=~ vsr(dsr(Year),units),
data=DT)
## ============================ ##
## example to use csr() structure (CUSTOMIZED)
## ============================ ##
unique(DT$Year)
mm <- matrix(1,3,3); mm[1,3] <- mm[3,1] <- 0;mm #don't estimate cov 2011-2013
mix <- mmer(Yield~Env,
random= ~ vsr(csr(Year,mm),Name),
rcov=~ vsr(dsr(Year),units),
data=DT)
## ============================ ##
## example to use overlay() + vsr() structure
## ============================ ##
data("DT_halfdiallel")
DT <- DT_halfdiallel
head(DT)
DT$femalef <- as.factor(DT$female)
DT$malef <- as.factor(DT$male)
DT$genof <- as.factor(DT$geno)
A <- diag(7); colnames(A) <- rownames(A) <- 1:7;A # if you want to provide a covariance matrix
#### model using overlay
modh <- mmer(sugar~1,
random=~vsr(overlay(femalef,malef,sparse=FALSE), Gu=A)
+ genof,
data=DT)
## ============================ ##
## example to use vsr() + dsr() + spl2D() structure
## ============================ ##
# ### mimic two fields
# data(DT_cpdata)
# DT <- DT_cpdata
# GT <- GT_cpdata
# MP <- MP_cpdata
# aa <- DT; bb <- DT
# aa$FIELD <- "A";bb$FIELD <- "B"
# set.seed(1234)
# aa$Yield <- aa$Yield + rnorm(length(aa$Yield),0,4)
# DT2 <- rbind(aa,bb)
# head(DT2)
#
# mix <- mmer(Yield~1,
# random=~vsr(dsr(FIELD),id, Gu=A) +
# vsr(dsr(FIELD),Rowf) +
# vsr(dsr(FIELD),Colf) +
# vsr(dsr(FIELD),spl2D(Row,Col)),
# rcov=~vsr(dsr(FIELD),units),
# data=DT2)
Run the code above in your browser using DataLab