[R] Tukey HSD plot with lines indicating (non-)significance

Karl Ove Hufthammer karl at huftis.org
Tue Jan 15 19:24:57 CET 2013


Thanks for the suggested code! It’s a very nice way of displaying most
aspects of the data and the HSD tests/CIs. The graphical display is
probably to big for inclusion in journal articles, but works well for
displaying the results when working with the data.


Regards,
Karl Ove Hufthammer


ty. den 15. 01. 2013 klokka 06.43 (-0500) skreiv Richard M. Heiberger:
> Karl, 
> 
> Thank you for this interesting challenge.  It turns out to be
> reasonably straightforward. This code does it for the first example
> in ?MMC. 
> 
> ## This example is based on the example in ?HH:::MMC 
> 
> library(HH) 
> 
> ## pairwise comparisons data(catalystm) 
> 
> 
> 
> ## A. individual plots 
> 
> ## base graphics box plot boxplot(concent ~ catalyst, data=catalystm,
> xlab="catalyst", ylab="concentration", las=1) 
> 
> ## aov catalystm1.aov <- aov(concent ~ catalyst, data=catalystm)
> summary(catalystm1.aov) 
> 
> ## MMC plot old.omd <- par(omd=c(0,.95,0,1)) catalystm.mmc <-
> mmc(catalystm1.aov, linfct = mcp(catalyst = "Tukey")) catalystm.mmc
> plot(catalystm.mmc, ry=c(50,58), x.offset=1.8) 
> 
> ## tiebreaker plot plotMatchMMC(catalystm.mmc$mca,
> xlabel.print=FALSE) 
> 
> 
> 
> 
> 
> ## B. coordinate scales of all three plots by adjusting par values and
> ##    the frame sizes 
> 
> def.par <- par(no.readonly = TRUE) # save default, for resetting... ##
> allocate figure 1 the right 2/3 and top 2/3 of the plotting region ##
> allocate figure 2 the right 2/3 and bottom 1/3 of the plotting region
> ## allocate figure 3 the left 1/3 and top 2/3 of the plotting region
> frame() layout(matrix(c(3,1,                 0,2), 2, 2, byrow =
> TRUE),        widths=c(1,2), heights=c(2,1)) ## show the regions that
> have been allocated to each plot layout.show(3) 
> 
> omd.old <- par(omd=c(0,.95,0,1)) plot(catalystm.mmc, ry=c(50,59),
> x.offset=1.8) usr.mmc <- par()$usr 
> 
> mar.old <- par(mar=c(5,4,0,2)+.1) plotMatchMMC(catalystm.mmc$mca,
> xlabel.print=FALSE) 
> 
> par(mar.old) boxplot(concent ~ catalyst, data=catalystm,
> xlab="catalyst", ylab="concentration", las=1,
> ylim=usr.mmc[3:4], yaxs="i") 
> 
> 
> 
> ## If you have a set of plots that don't fit comfortably into the ##
> space illustrated here, then you will need to increase the plotting ##
> device window from the default 7in x 7in because the cex is ##
> hardwired into the plot.mmc.multicomp function. 



More information about the R-help mailing list