# An example of a split-plot design with randomized block whole plot structure. # Taken from Kuehls text "Design of Experiments: Statistical Principles of Research # Design and Analysis" Second Edition # The whole plot factor is 'source', and the split-plot factor is 'yrsaccum' data <- scan(what = list(source="",block=0,yrsaccum=0,chlor=0), multi.line=F) Urea 1 2 3.8 Urea 1 5 5.3 Urea 1 8 5.9 Urea 2 2 3.9 Urea 2 5 5.4 Urea 2 8 4.3 Ammsul 1 2 5.2 Ammsul 1 5 5.6 Ammsul 1 8 5.4 Ammsul 2 2 6.0 Ammsul 2 5 6.1 Ammsul 2 8 6.2 IBDU 1 2 6.0 IBDU 1 5 5.6 IBDU 1 8 7.8 IBDU 2 2 7.0 IBDU 2 5 6.4 IBDU 2 8 7.8 UreaSC 1 2 6.8 UreaSC 1 5 8.6 UreaSC 1 8 8.5 UreaSC 2 2 7.9 UreaSC 2 5 8.6 UreaSC 2 8 8.4 data table142 <- data.frame(data) rm(data) table142$source <- as.factor(table142$source) table142$block <- as.factor(table142$block) table142$yrsaccum <- as.factor(table142$yrsaccum) # Using the afex package to get results like Proc Mixed library(afex) table142.afex1 <- mixed(chlor ~ source + (1|block) +(1|source:block) +yrsaccum +source:yrsaccum, data = table142) summary(table142.afex1) nice(table142.afex1) lsmeans(table142.afex1, ~source) lsmeans(table142.afex1, ~yrsaccum) lsmeans(table142.afex1, ~source:yrsaccum) lsmip(table142.afex1, source ~ yrsaccum) lsmip(table142.afex1, yrsaccum ~ source) # check assumptions # for a normal plot, use the qqnorm and qqline functions applied as below: qqnorm(summary(table142.afex1)$residuals) qqline(summary(table142.afex1)$residuals) # get a residual by predicted plot from the lmer function library(lme4) table142.lme1 <- lmer(chlor ~ source + (1|block) +(1|source:block) +yrsaccum +source:yrsaccum, data = table142) plot(table142.lme1)