set.seed(1)
data(wheat)
## Scale yields to reproduce analyses reported in Vargas et al (2001)
yield.scaled <- wheat$yield * sqrt(3/1000)
## Reproduce (up to error caused by rounding) Table 1 of Vargas et al (2001)
aov(yield.scaled ~ year*tillage*summerCrop*manure*N, data = wheat)
treatment <- interaction(wheat$tillage, wheat$summerCrop, wheat$manure,
wheat$N, sep = "")
mainEffects <- lm(yield.scaled ~ year + treatment, data = wheat)
svdStart <- residSVD(mainEffects, year, treatment, 3)
bilinear1 <- update(asGnm(mainEffects), . ~ . +
Mult(year - 1, treatment - 1),
start = c(coef(mainEffects), svdStart[,1]))
bilinear2 <- update(asGnm(mainEffects), . ~ . +
Mult(year - 1, treatment - 1, multiplicity = 2),
start = c(coef(mainEffects), svdStart[,1:2]))
bilinear3 <- update(asGnm(mainEffects), . ~ . +
Mult(year - 1, treatment - 1, multiplicity = 3),
start = c(coef(mainEffects), svdStart[,1:3]))
anova(mainEffects, bilinear1, bilinear2, bilinear3)
## Examine the extent to which, say, mTF explains the first bilinear term
bilinear1mTF <- gnm(yield.scaled ~ year + treatment + Mult(1 + mTF, treatment),
family = gaussian, data = wheat)
anova(mainEffects, bilinear1mTF, bilinear1)
Run the code above in your browser using DataLab