2

I used lme4 to run a mixed effects logistig regression (by calling glmer) in R and now I am trying to do post-hoc comparisons. As they are pairwise, Tukey should be OK,but I would like to manually adjust for how many tests the correction should be made - now it is made for 12 tests, but I am only intersted in 6 comparisons.

My code looks like this so far

    for (i in seq_along(logmixed_ranks)) {
    print(lsmeans(logmixed_ranks[[i]], pairwise~rating_ranks*indicator_var, adjust="tukey"))
    }

Somehow I may need to use the following but I am not sure how.

      p.adjust(p, method = p.adjust.methods, n = length(p))

Can anybody help? Thanks! Laura

LaNeu
  • 105
  • 14
  • I suggest to use `glht` from package multcomp: http://www.inside-r.org/packages/cran/multcomp/docs/glht – Roland Mar 12 '15 at 13:04
  • thanks - does it work with the interaction term though? I cannot figure that out (it only works without the interaction for me)... thanks! – LaNeu Mar 12 '15 at 13:41
  • Assuming your IVs are all factors, you could just reparameterize the model, e.g., from `z ~ x * y + (1|g)` to `i <- interaction(x, y); z ~ i + (1|g)`. That's what I usually do. – Roland Mar 12 '15 at 13:44
  • thanks, works for well for me with this interaction term. How would you adjust for multiple testing? (i.e., 6 test but I get more contrasts) - is the default, single-step, fine? Thanks! – LaNeu Mar 12 '15 at 17:07
  • `glht` allows you to specify exactly which comparisons you want to test. – Roland Mar 13 '15 at 07:58

1 Answers1

0

There must be a reason you want to adjust for only 6 comparisons, and I'm guessing is it is because you want to break down the comparisons you're doing conditionally on one of the factors. This is easy to do using lsmeans:

lsmeans(logmixed_ranks[[i]], 
    pairwise ~ rating_ranks | indicator_var, adjust = "tukey")

or

lsmeans(logmixed_ranks[[i]], 
    pairwise ~ indicator_var | rating_ranks, adjust = "tukey")

By the way, if you use adjust = "mvt", you will obtain exactly the same adjustments that glht uses for its single-step procedure. So I believe the only glht features not supported by lsmeans are the multi-step tests.

I'm puzzled by why you have a list of glmer objects, but that does not seem germane to my answer.

Russ Lenth
  • 5,922
  • 2
  • 13
  • 21
  • Thanks a lot. Both answers (i.e., one answer and one comment) helped a lot, both differently. – LaNeu Mar 17 '15 at 07:35