# NOT RUN {
require(lsmeans)
warp.lm <- lm(breaks ~ wool*tension, data = warpbreaks)
warp.lsm <- lsmeans(warp.lm, ~ tension | wool)
# Polynomial contrasts of tension, by wool
(warp.pl <- contrast(warp.lsm, "poly", name = "order"))
# Same results with a different adjustment
summary(warp.pl, adjust = "fdr")
# Jointly test the tension effects for each wool
test(warp.pl, joint = TRUE, by = "wool")
# Compare the two contrasts for each order
contrast(warp.pl, "revpairwise", by = "order")
# User-provided contrasts, ignoring the previous by grouping
contrast(warp.lsm,
list(c1=c(1,0,0,-1,0,0), c2=c(1,1,1,-1,-1,-1)/3),
by = NULL)
# Compare consecutive tension*wool comb's as treatment with 6 levels
contrast(warp.lsm, "consec", by = NULL)
# Interaction contrasts (comparisons of linear and quadratic contrasts)
(int.con <- contrast(warp.lsm, interaction = c("poly", "consec"), by = NULL))
# See the contrast coefficients used by the previous call
coef(int.con)
# }
Run the code above in your browser using DataLab