lsmip {lsmeans} | R Documentation |
This function creates an interaction plot of the least-squares means based on a fitted model and a simple formula specification.
## Default S3 method: lsmip(object, formula, type, pch = c(1,2,6,7,9,10,15:20), lty = 1, col = NULL, plotit = TRUE, ...) pmmip(...)
object |
An object of class |
formula |
Formula of the form |
type |
As in |
pch |
The plotting characters to use for each group (i.e., levels of |
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. |
plotit |
If |
... |
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 lsmobj
object, its first element is used, and it must contain one lsmean
value for each combination of the factors present in formula
.
The wrapper pmmip
is provided for those who prefer the term ‘predicted marginal means’.
(Invisibly), a data.frame
with the table of least-squares means that were plotted, with an additional "lattice"
attribute containing the trellis
object for the plot.
This function uses the xyplot
function in the lattice
package (an error is returned if lattice
is not installed). Conceptually, it is equivalent to interaction.plot
where the summarization function is the least-squares means.
Russell V. Lenth
require(lsmeans) require(lattice) #--- 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))