Learn R Programming

lsmeans (version 1.10-3)

lsmip: Least-squares means interaction plot

Description

This function creates an interaction plot of the least-squares means based on a fitted model and a simple formula specification.

Usage

lsmip(object, formula, pch = c(1,2,6,7,9,10,15:20), lty = 1, col = NULL, ...)

Arguments

object
An object of class lsm, or a fitted model of a class supported by lsmeans.
formula
Formula of the form trace.factors ~ x.factors | by.factors. The least-squares means are plotted against x.factor for each level of trace.factors. by.factors is optional, but if present, it determines sep
pch
The plotting characters to use for each group (i.e., levels of trace.factors). They are recycled as needed.
lty
The line types to use for each group. Recycled as needed.
col
The colors to use for each group, recycled as needed. If not specified, the default trellis colors are used.
...
Additional arguments passed to lsmeans or to xyplot.

Value

  • (Invisibly), the table of least-squares means that were plotted.

Details

If object is a fitted model, lsmeans is called with an appropriate specification to obtain least-squares means for each combination of the factors present in formula (in addition, any arguments in ... that match at, trend, cov.reduce, or fac.reduce are passed to lsmeans). Otherwise, if object is an lsm object, its first element is used, and it must contain one lsmean value for each combination of the factors present in formula.

See Also

interaction.plot

Examples

Run this code
#--- Two-factor example
warp.lm <- lm(breaks ~ wool * tension, data = warpbreaks)

# Following plot is the same as the usual interaction plot of the data
lsmip(warp.lm, wool ~ tension)

#--- Three-factor example
noise.lm = lm(noise ~ size * type * side, data = auto.noise)

# Separate interaction plots of size by type, for each side
lsmip(noise.lm, type ~ size | side)

# One interaction plot, using combinations of size and side as the x factor
lsmip(noise.lm, type ~ side * size)

# One interaction plot using combinations of type and side as the trace factor
# customize the colors, line types, and symbols to suggest these combinations
lsmip(noise.lm, type * side ~ size, lty=1:2, col=1:2, pch=c(1,1,2,2))

# 3-way interaction is significant, but doesn't make a lot of visual difference...
noise.lm2 = update(noise.lm, . ~ . - size:type:side)
lsmip(noise.lm2, type * side ~ size, lty=1:2, col=1:2, pch=c(1,1,2,2))

Run the code above in your browser using DataLab