#--- 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