I have an unbalanced linear mixed effects model with three fixed factors of various levels and one random factor for my repeated measures data (for details see here). Thanks to your help I managed to do post-hoc tests on the significant interaction terms using lsm from the lsmeans package. However, I need to report the F statistic (F value and degrees of freedom) for these post-hoc tests and wonder how???

Here is what I do:

  1. Model comparison using anova() resulting into the final model model_final, which reads:

    sc ~ time + cond + place + time:cond + cond:place + (1|ID), data) .

  2. I analyze the significant interaction time:cond using lsmeans:

    posthoc_1 <- glht(model_final, lsm(pairwise ~ cond|time)


and get sth like below for each level of time, here is the example for time1.

> Note: df set to 268 
> $`time = time1`
>    Simultaneous Tests for General Linear Hypotheses
> Fit: lme4::lmer(formula = sc ~ time + cond + place + time:cond + cond:place + (1|ID), data)
> Linear Hypotheses:
>                    Estimate Std. Error t value Pr(>|t|) 
> cond1 - cond2 == 0   3.1867     0.6797   4.688 4.39e-06 ***

This gives me t-values for the various levels of the interaction terms and their corresponding p-value, but no F stats!

My questions:

  1. Is there any way of obtaining the F stats? (F value and degree of freedom)
  2. Or am I stuck with the t-values? If so, is t(0.095;268) = 4.588, p < 0.001 reporting the correct degrees of freedom?

1 Answer 1


If you use the lsmeans function directly rather than via glht, you might have better luck.

( mod.pairs = contrast(lsmeans(model_final, ~ cond|time), "trt.vs.ctrl1") )

At this point, what you have is pairwise comparisons at each time. Is it the cond:time interaction you want to test? If so, compute contrasts of the above differences (column labeled contrast):

inter.con = contrast(mod.pairs, "trt.vs.ctrl1", by = NULL)
test(inter.con, joint = TRUE)

I'm suggesting using trt.vs.ctrl1 contrasts because it makes the right number of contrasts to match the d.f. However if you use pairwise instead, it will give the same results (it will just have to work harder).

PS this does require the latest version of lsmeans (2.12) because the joint option was not avaialble before then.

  • $\begingroup$ Thanks, rvl, yes, it is the cond:time interaction I want to test to see at which time the two levels of cond differ significantly. The first two lines of code give me the exact same output as the lsm() command within glht, so that's fine. I'm afraid, I don't understand what you are doing with the last bit of code (inter.con and then the test()-bit). Do I actually make contrasts of contrasts there? I do not want an overall F stat but an F stat for each cond-comparison of every level of time. $\endgroup$ Commented Oct 16, 2014 at 16:22
  • 1
    $\begingroup$ Yes. Interactions are quantified by taking contrasts of contrasts. If you want $F$ tests for individual contrasts, just compute $F=t^2$ with $(1,df)$ degrees of freedom. $\endgroup$
    – Russ Lenth
    Commented Oct 16, 2014 at 17:14
  • $\begingroup$ Ah, now I get it :-) The quantification of the interaction I actually already got with anova(model_final). Squaring the t value is what I resigned to, too, but I thought there might be a more elegant way... Thanks anyway! $\endgroup$ Commented Oct 16, 2014 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.