# NOT RUN {
### ========================== ###
### using the mmer2 function
### ========================== ###
data(yates.oats)
head(yates.oats)
m3 <- mmer2(fixed=Y ~ V + N + V:N, random = ~ B + B:MP,
data = yates.oats)
summary(m3)
m3$var.comp
### ========================== ###
### using the mmer function
### ========================== ###
###response
y<-yates.oats$Y
###fixed effects
X1 <- model.matrix(~V*N,yates.oats)
###random effects
Z1 <- model.matrix(~B-1, yates.oats)
Z2 <- model.matrix(~B:MP-1, yates.oats)
ETA <- list(B=list(Z=Z1),BMP=list(Z=Z2))
###run the model
m4 <- mmer(Y=y,X=X1,Z=ETA)
summary(m4)
# }
Run the code above in your browser using DataLab