library(predictmeans)
# ftable(xtabs(yield ~ Block+Variety+nitro, data=Oats))
Oats$nitro <- factor(Oats$nitro)
fm <- lme(yield ~ nitro*Variety, random=~1|Block/Variety, data=Oats)
# library(lme4)
# fm <- lmer(yield ~ nitro*Variety+(1|Block/Variety), data=Oats)
## Not run:
## The contrast has a contrast matrix as follows:
# 0:Golden Rain 0:Marvellous 0:Victory
#[1,] -1 0 1
#[2,] 0 0 1
# 0.2:Golden Rain 0.2:Marvellous 0.2:Victory
#[1,] 0 0 0
#[2,] 0 0 0
# 0.4:Golden Rain 0.4:Marvellous 0.4:Victory
#[1,] 0 0 0
#[2,] 0 -1 0
# 0.6:Golden Rain 0.6:Marvellous 0.6:Victory
#[1,] 0 0 0
#[2,] 0 0 0
# 1. Enter above contrast matrix into a pop up window, then close the window
# contrastmeans(fm, "nitro:Variety")
# 2. Construct the contrast matrix directly
cm <- rbind(c(-1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0),
c(0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0))
contrastmeans(fm, "nitro:Variety", ctrmatrix=cm)
Run the code above in your browser using DataLab