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