if (FALSE) {
library(agridat)
data(montgomery.wheat.uniformity)
dat <- montgomery.wheat.uniformity
dat09 <- subset(dat, year==1909)
dat11 <- subset(dat, year==1911)
# Match the figures of Montgomery 1912 Fig 3, p. 178
libs(desplot)
desplot(dat09, yield ~ col*row,
aspect=1, # true aspect
main="montgomery.wheat.uniformity - 1909 yield")
desplot(dat, yield ~ col*row, subset= year==1911,
aspect=1, # true aspect
main="montgomery.wheat.uniformity - 1911 yield")
# Surface & Pearl adjust 1909 yield for fertility effects.
# They calculate smoothed yield as (row sum)*(column sum)/(total)
# and subtract this from the overall mean to get 'deviation'.
# We can do something similar with a linear model with rows and columns
# as factors, then predict yield to get the smooth trend.
# Corrected yield = observed - deviation = observed - (smooth-mean)
m1 <- lm(yield ~ factor(col) + factor(row), data=dat09)
dev1 <- predict(m1) - mean(dat09$yield)
# Corrected. Similar (but not exact) to Surface, fig 2.
dat09$correct <- round(dat09$yield - dev1,0)
libs(desplot)
desplot(dat09, yield ~ col*row,
shorten="none", text=yield,
main="montgomery.wheat.uniformity 1909 observed")
desplot(dat09, correct ~ col*row, text=correct,
cex=0.8, shorten="none",
main="montgomery.wheat.uniformity 1909 corrected")
# Corrected yields are slightly shrunk toward overall mean
plot(correct~yield,dat09, xlim=c(350,1000), ylim=c(350,1000))
abline(0,1)
}
Run the code above in your browser using DataLab