if (FALSE) {
library(agridat)
data(tesfaye.millet)
dat <- tesfaye.millet
dat <- transform(dat, year=factor(year), site=factor(site))
libs(dplyr,asreml,lucid)
dat <- mutate(dat,
env=factor(paste0(site,year)),
gen=factor(gen),
rep=factor(rep),
xfac=factor(col), yfac=factor(row))
libs(desplot)
desplot(dat, yield~col*row|env, main="tesfaye.millet")
dat <- arrange(dat, env, xfac, yfac)
# Fixed environment
# Random row/col within environment, Factor Analytic GxE
# AR1xAR1 spatial residuals within each environment
if(require("asreml", quietly=TRUE)){
libs(asreml)
m1 <- asreml(yield ~ 1 + env,
data=dat,
random = ~ at(env):xfac + at(env):yfac + gen:fa(env),
residual = ~ dsum( ~ ar1(xfac):ar1(yfac)|env) )
m1 <- update(m1)
lucid::vc(m1)
}
}
Run the code above in your browser using DataLab