if (FALSE) {
library(agridat)
data(omer.sorghum)
dat <- omer.sorghum
# REML approach
libs(lme4)
libs(lucid)
# 1 loc, 2 years. Match Omer table 1.
m1 <- lmer(yield ~ 1 + env + (1|env:rep) + (1|gen) + (1|gen:env),
data=subset(dat, is.element(env, c('E2','E4'))))
vc(m1)
## grp var1 var2 vcov sdcor
## gen:env (Intercept) 17050 130.6
## gen (Intercept) 2760 52.54
## env:rep (Intercept) 959.1 30.97
## Residual 43090 207.6
# 1 loc, 3 years. Match Omer table 1.
m2 <- lmer(yield ~ 1 + env + (1|env:rep) + (1|gen) + (1|gen:env),
data=subset(dat, is.element(env, c('E2','E4','E6'))))
vc(m2)
## grp var1 var2 vcov sdcor
## gen:env (Intercept) 22210 149
## gen (Intercept) 9288 96.37
## env:rep (Intercept) 1332 36.5
## Residual 40270 200.7
# all 6 locs. Match Omer table 3, frequentist approach
m3 <- lmer(yield ~ 1 + env + (1|env:rep) + (1|gen) + (1|gen:env),
data=dat)
vc(m3)
## grp var1 var2 vcov sdcor
## gen:env (Intercept) 21340 146.1
## env:rep (Intercept) 1152 33.95
## gen (Intercept) 1169 34.2
## Residual 24660 157
}
Run the code above in your browser using DataLab