Dear R community; I'm trying to replicate an example I found on a publication using the following data dat <- data.frame(F = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3), T c(1,1,1,1,1,1,1,1,2,2,2, 2,2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2), R c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9, 10,10,10,10,11,11,11,11,12,12,12,12), E c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41, 42,43,44,45,46,47,48), HT c(7.3,10.3,14.8,2.9,14.9,1.8,5.1,17.7,14.1,13,19.3, 20.7,24.9,16,14.9,24.9,24.3,28.6,31.8,32.7,29.1,24.7,30.1,31.9,42.2,45.6,40.7, 34.5,38.4,46.4,38,41.7,50.7,53.2,50.1,41.4,53,37.9,50.9,51,69.5,53.8,53.8,62.1, 54.3,63,47,65.4)) F, T are two treatments R is a row of plants nested within F & T (according to the example) E are the plants within the rows R The experimental unit is R but the example considers subsampling, so in other words, the idea is to use all the data at plant-level (E) for the analysis instead of the row-level means. The SAS model used in the example is PROC GLM DATA=dat; CLASS F T R; MODEL HT = F|T R(F T); TEST H = F|T E=R(F T); CONTRAST 'First vs Third in F' F -1 0 1 / E = R(F T); MEANS F / LSD E = R(F T) CLDIFF; RUN; My R version looks like options(contrasts = c("contr.SAS", "contr.poly")) dat$F <- as.factor(dat$F) dat$T <- as.factor(dat$T) dat$R <- as.factor(dat$R) m2 <- aov(HT ~ F*T + Error(R/F*T), data = dat) summary(m2) which gives me similar results to the SAS example. However, I haven't been able to replicate the CONTRAST and MEANS commands I'd appreciate any hint (maybe using lmer instead?) Thanks in advance ************************************************************************************ SAS output attached as pdf -------------- next part -------------- A non-text attachment was scrubbed... Name: anovaexamples.pdf Type: application/pdf Size: 154055 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20140420/ddffd6f1/attachment-0002.pdf>