# NOT RUN {
data(genericData)
mod <- lm(Y~A,data=genericData)
dfModel <- anovaTable(mod)['Model','df']
dfError <- anovaTable(mod)['Residual','df']
mse <- anovaTable(mod)['Residual','MS']
meanVec <- aggregate(Y~A,FUN=mean,data=genericData)$Y
n <- aggregate(Y~A,FUN=length,data=genericData)$Y
## can add names for ease of interpretation with the output
names(meanVec) <- c('group 1','group 2','group 3')
contrastTest(estVec=meanVec,n=n,dfModel=dfModel,dfError=dfError,mse=mse,test='hsd')
## each group vs the mean of the other two
C <- rbind(c(1,-0.5,-0.5),c(-0.5,1,-0.5),c(-0.5,-0.5,1))
## row names are not required but are helpful
row.names(C) <- c('1 vs 2+3','2 vs 1+3','3 vs 1+2')
contrastTest(estVec=meanVec,n=n,dfModel=dfModel,dfError=dfError,mse=mse,C=C,test='scheffe')
# }
Run the code above in your browser using DataLab