# Between group comparison for every level of within factor

If I use lme for mixed ANOVA as follow

lme_model=lme(dv ~ between*within, data frame, random=~1|ID, correlation=corCompSymm(form=~1|ID))


how can I perform between group comparison for every level of within factor?

This great answer advice to use anova with L argument. But I can't understand how.

Thanks for the help

• Did you try the lsmeans and multcomp packages ? – Stéphane Laurent Feb 11 '13 at 21:55
• Thank you. Lsmeans is what I am looking for. multcomp with summary(glht(lme_model, linfct=mcp(between = "Tukey")), test = adjusted(type = "fdr")) lead to warning In mcp2matrix(model, linfct = linfct) : covariate interactions found -- default contrast might be inappropriate. Is lsmeans concerned about covariate interactions? – sviter Feb 12 '13 at 8:35
• I think there are significant interactions in your fitting and then you get a warning about comparing main effects in such a situation because this comparison is possibly meaningless. – Stéphane Laurent Feb 12 '13 at 9:23
• Sorry, but I don't understand your last thought. I decided to use lsmeans(lme_model, pairwise ~ between | within). – sviter Feb 12 '13 at 9:36
• When you have a model with two factors, say A and B, it is not pertinent to assess the effect of these factors when the interaction A:B is significant. I think multcompand/or lsmeans returns a warning in such situations. – Stéphane Laurent Feb 12 '13 at 9:40

If you are looking for post-hoc tests you should find additional functions in R such as TukeyHSD for example.

If you want to perform planned comparisons with your anova, I am used to enter directly contrast codes in the linear model.

I found a simple example here