Learn R Programming

lsmeans (version 1.10-00)

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)

#--- Four-factor example from Box, Hunter, Hunter (2nd ed) p. 199
process <- expand.grid(Catalyst=factor(c(10,15)), Temp=factor(c(220,240)), 
                       Pressure=factor(c(50,80)), Conc=factor(c(10,12)))
process$Conversion <- c(70,60,89,81,69,62,88,81,60,49,88,82,60,52,86,79)
process.lm <- lm(Conversion ~ Catalyst*Temp*Pressure*Conc, data = process)

op <- options(warn=-1) # zero df for error, suppress warnings

# Multi-panel interaction plot
lsmip(process.lm, Catalyst ~ Temp | Pressure*Conc)

# One panel using different factor combinations and custom symbols and lines 
lsmip(process.lm, Catalyst*Temp ~ Pressure*Conc, 
      lty=1:2, col=1:2, pch=c(1,1,2,2))

# Simplified model with just one two-way interaction
process.lm2 <- update(process.lm, . ~ Catalyst + Pressure + Temp*Conc)
lsmip(process.lm2, Catalyst*Temp ~ Pressure*Conc, 
      lty=1:2, col=1:2, pch=c(1,1,2,2))

options(op)

Run the code above in your browser using DataLab