data <- scan(what = list(block=0,treatment="",y=0,x=0), multi.line=F) 1 Check 23.1 13 1 Full 30.1 7 1 N0 26.4 10 1 P0 26.2 8 2 Check 20.9 12 2 Full 31.8 5 2 N0 27.2 9 2 P0 25.3 9 3 Check 28.3 7 3 Full 32.4 6 3 N0 28.6 6 3 P0 29.7 7 4 Check 25.0 9 4 Full 30.6 7 4 N0 28.5 6 4 P0 26.0 7 5 Check 25.1 8 5 Full 27.5 9 5 N0 30.8 5 5 P0 24.9 9 data table17.7 <- data.frame(data) rm(data) table17.7$block <- as.factor(table17.7$block) table17.7$treatment <- as.factor(table17.7$treatment) # look at the data plot(table17.7$x,table17.7$y,pch=as.numeric(table17.7$treatment), col=as.numeric(table17.7$treatment),ylab="y",xlab="x") legend("topright",levels(table17.7$treatment),pch=1:4,col=1:4) # standard ANCOVA assuming equal slopes # first declare 'treatment' to be an ordered factor with 'Full' as the # first level, so that Dunnett's test will compare all levels to it table17.7$treatment <- ordered(table17.7$treatment, levels = c("Full","Check","N0","P0")) tab17.7.lm1 <- lm(y ~ x +block +treatment , data=table17.7) anova(tab17.7.lm1) summary(tab17.7.lm1) # check assumptions windows() par(mfrow=c(2,2)) plot(tab17.7.lm1) par(mfrow=c(1,1)) # calculate adjustedMeans and standard errors from the effects package library(effects) adjustedMeans <- effect("treatment",tab17.7.lm1) adjustedMeans adjustedMeans$se # multiple comparisons using the multcomp package # using Dunnett's method against the first level (defined as "Full" above) library(multcomp) summary(glht(tab17.7.lm1,linfct=mcp(treatment="Dunnett")))