d1 <- durban.rowcol
desplot(yield~bed*row, d1, out1=rep)
# Durban 2003 Figure 1
m10 <- lm(yield~gen, data=d1)
d1$resid <- m10$resid
require(lattice)
xyplot(resid~row, d1, type=c('p','smooth'))
xyplot(resid~bed, d1, type=c('p','smooth'))
# Figure 3
coplot(resid~bed|factor(row), data=d1, cex=.5,
panel=function(x,y,...) panel.smooth(x,y,span=.75,...))
# Figure 5 - field trend
require(gam)
m1lo <- gam(yield ~ gen + lo(row, span=10/16) + lo(bed, span=9/34), data=d1)
new1 <- expand.grid(row=unique(d1$row),bed=unique(d1$bed))
new1 <- cbind(new1, gen="G001")
p1lo <- predict(m1lo, new=new1)
wireframe(p1lo~row+bed, new1, aspect=c(1,.5), main="Field trend") # Figure 5
require(asreml)
d1 <- transform(d1, rowf=factor(row), bedf=factor(bed))
d1 <- d1[order(d1$rowf, d1$bedf),]
m1a1 <- asreml(yield~gen + lin(rowf) + lin(bedf), data=d1,
random=~spl(rowf) + spl(bedf) + units,
family=asreml.gaussian(dispersion=1))
m1a2 <- asreml(yield~gen + lin(rowf) + lin(bedf), data=d1,
random=~spl(rowf) + spl(bedf) + units, rcov=~ar1(rowf):ar1(bedf))
m1a3 <- asreml(yield~gen, data=d1, random=~units, rcov=~ar1(rowf):ar1(bedf))
# Figure 7
v7a <- asreml.variogram(x=d1$bedf, y=d1$rowf, z=resid(m1a3))
wireframe(gamma ~ x*y, v7a, aspect=c(1,.5)) # Fig 7a
v7b <- asreml.variogram(x=d1$bedf, y=d1$rowf, z=resid(m1a2))
wireframe(gamma ~ x*y, v7b, aspect=c(1,.5)) # Fig 7b
v7c <- asreml.variogram(x=d1$bedf, y=d1$rowf, z=resid(m1lo))
wireframe(gamma ~ x*y, v7c, aspect=c(1,.5)) # Fig 7cRun the code above in your browser using DataLab