[R] ANOVA and confidence intervals plot

Richard M. Heiberger rmh at temple.edu
Mon Apr 2 04:40:01 CEST 2007


> 	I would like to obtain for each factor of my anova model the  
> "response variable vs factor" plot with means and 95% Tukey HSD  
> intervals.

I believe you are asking for the multiple comparisons plots from the
multcomp package.  The example below is an extension of one of the
examples in ?glht:


library(multcomp)
      ### multiple comparison procedures
       ### set up a one-way ANOVA
       amod <- aov(breaks ~ tension, data = warpbreaks)

       ### set up all-pair comparisons for factor `tension'
       ### using a symbolic description (`type' argument 
       ### to `contrMat()')
warp.mca <- glht(amod, linfct = mcp(tension = "Tukey"))

confint(warp.mca)
plot(warp.mca)


You asked about the level means themselves, rather than the pairwise
comparisons above.  That is done with

warp.pairwise <- glht(amod, linfct = mcp(tension = "Means"))
confint(warp.pairwise)
plot(warp.pairwise)


I recommend the MMC (Mean-mean Multiple Comparison) plot that includes
both sets of information, pairwise comparisons and individual means, and
also allows arbitrary contrasts.

library(HH)
warp.mmc <- glht.mmc(amod, linfct = mcp(tension = "Tukey"))
warp.mmc
plot(warp.mmc)


See the help files
?glht
?mmc
for more details.  Both glht and glht.mmc extend to multi-way designs.



More information about the R-help mailing list