HH (version 2.2-17)

interaction2wt: Plot all main effects and twoway interactions in a multifactor design

Description

The main diagonal displays boxplots for the main effects of each factor. The off-diagonals show the interaction plots for each pair of factors. The i,j panel shows the same factors as the j,i but with the trace- and x-factor roles interchanged.

Usage

interaction2wt(x, ...)

## S3 method for class 'formula':
interaction2wt(x, data = sys.parent(), responselab, ...)

## S3 method for class 'default':
interaction2wt(x,
               response.var,
               responselab = deparse(substitute(response.var)),
               responselab.expression = responselab,
               relation = list(x = "same", y = "same"),
               x.relation = relation$x,
               y.relation = relation$y,
               digits = 3,
               x.between=if (label.as.interaction.formula) 0 else 1,
               y.between=if (label.as.interaction.formula) 0 else 1,
               between,
               cex = 0.75,
               rot=c(0,0),
               panel.input = panel.interaction2wt,
               strip.input =
                if (label.as.interaction.formula) strip.default
                else strip.interaction2wt,
               par.strip.text.input = trellis.par.get()$add.text,
               scales.additional,
               main.in =
                 paste(responselab,
                       ": main effects and 2-way interactions",
                       sep = ""),
               xlab = "",
               ylab = "",
               simple=FALSE,
               box.ratio=if (simple) .32 else 1,
               label.as.interaction.formula=TRUE,
               ...,
               main.cex,
               key.cex.title=trellis.par.get()$par.xlab.text$cex,
               key.cex.text=trellis.par.get()$axis.text$cex,
               factor.expressions=names.x
)

Arguments

Value

"trellis" object containing the plot.

References

Heiberger, Richard M. and Holland, Burt (2004b). Statistical Analysis and Data Display: An Intermediate Course with Examples in S-Plus, R, and SAS. Springer Texts in Statistics. Springer. ISBN 0-387-40270-5.

See Also

panel.interaction2wt

Examples

Run this code
vulcan <- read.table(hh("datasets/vulcan.dat"), header=TRUE)
vulcan$filler <- factor(vulcan$filler)
position(vulcan$raw) <- (1:4)+.5
position(vulcan$pretreat) <- 2:4
if.R(s={old.omd=par(omd=c(.1,1,.03,1))}, r={})
if.R(r=
     interaction2wt(wear ~ filler + pretreat + raw, data=vulcan,
                    par.strip.text=list(cex=.8))
     ,s=
     interaction2wt(wear ~ filler + pretreat + raw, data=vulcan,
                    par.strip.text=list(cex=.8),
                    key.in=list(x=-3.5))
)
interaction2wt(wear ~ filler + raw, data=vulcan,
               simple=TRUE)
interaction2wt(wear ~ filler + raw, data=vulcan,
               simple=TRUE, simple.scale=c(filler=.15, raw=.2),
               xlim=c(.3, 5.6))
if.R(s={par(old.omd)}, r={})

if.R(r={
  ToothGrowth <- ToothGrowth  ## local copy
  ToothGrowth$dose <- positioned(ToothGrowth$dose) ## modify local copy
print(
  anova(aov(len ~ supp*dose, data=ToothGrowth))
)
print(
  interaction2wt(len ~ supp + dose, data=ToothGrowth)
)

esoph=esoph
esoph$rate=with(esoph, ncases/ncontrols)

position(esoph$alcgp) <- 2:5
position(esoph$tobgp) <- 2:5

print(
interaction2wt(rate ~ agegp + alcgp + tobgp, esoph, rot=c(90,0),
               par.strip.text=list(cex=.8))
)

old.cex <- trellis.par.set(par.xlab.text=list(cex=.8))
print(
interaction2wt(rate ~ agegp + alcgp + tobgp, esoph, rot=c(90,0),
               par.strip.text=list(cex=.8),
               factor.expressions=c(
                  agegp=expression(Age~~(years)),
                  alcgp=expression(Alcohol~
                                   bgroup("(",scriptstyle(frac(gm, day)),")")),
                  tobgp=expression(Tobacco~
                                   bgroup("(",scriptstyle(frac(gm,
day)),")"))),
                  responselab.expression="Cancer
Rate",
           main.in="Esophogeal Cancer Rate ~ Alcohol Consumption + Tobacco Consumption", main.cex=1.2)
)

par(old.cex)

esoph.aov <- aov(rate ~ agegp + alcgp + tobgp, data=esoph)
print(
anova(esoph.aov)
)
}, s={})

Run the code above in your browser using DataLab