HH (version 3.1-39)

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 formula interaction2wt(x, data = sys.parent(), responselab, ...)

# S3 method for 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=1, y.between=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, ": ", c("main", "simple")[1+simple], " 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=.8, key.cex.text=.7, factor.expressions=names.x, simple.pch=NULL )

Arguments

x

The object on which method dispatch is carried out.

For the "formula" method, a formula describing the response variable and factors. The formula is generally of the form y ~ g1 + g2 + …. There may be one or more factors in the formula.

For the "default" method, data.frame of factors. This is usually constructed by formula method from the input data and the input formula.

data

For the formula method, a data frame containing values for any variables in the formula. In the R version, if not found in data, or if data is unspecified, the variables are looked for in the environment of the formula.

responselab

Character name of response variable, defaults to the name of the response variable in the formula.

responselab.expression

plotmath or character name of response variable, defaults to responselab.

additional arguments, primarily trellis arguments.

response.var

For the "default" method, the response variable. This is usually constructed by formula method from the input data and the input formula.

simple

logical. TRUE if simple effects are to be displayed. Arguments simple.offset, simple.scale, and col.by.row may also be needed. See panel.interaction2wt for details.

box.ratio

Value

"trellis" object containing the plot.

References

Heiberger, Richard M. and Holland, Burt (2015). Statistical Analysis and Data Display: An Intermediate Course with Examples in R, Second Edition. Springer Texts in Statistics. Springer. ISBN 978-1-4939-2121-8.

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
# NOT RUN {
data(vulcan)
interaction2wt(wear ~ filler + pretreat + raw, data=vulcan,
               par.strip.text=list(cex=.7))
interaction2wt(wear ~ filler + pretreat + raw, data=vulcan)
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))

ToothGrowth$dose <- positioned(ToothGrowth$dose) ## modify local copy
anova(aov(len ~ supp*dose, data=ToothGrowth))
interaction2wt(len ~ supp + dose, data=ToothGrowth)


esoph$rate=with(esoph, ncases/ncontrols) ## modify local copy

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

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

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)),")"))),
               par.settings=list(
                 par.xlab.text=list(cex=.8),
                 par.ylab.text=list(cex=.8)),
               responselab.expression="Cancer\nRate",
               main=list(
"Esophogeal Cancer Rate ~ Alcohol Consumption + Tobacco Consumption",
                 cex=1.2))

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

# }

Run the code above in your browser using DataCamp Workspace