Skip to content
Prev 14582 / 20628 Next

P-values from interaction terms using lme4

Hi Sam,

if you're getting p-values from lmer outside of a likelihood-ratio test,
then you're using lmerTest, not lme4. lmerTest is designed to be a
drop-in replacement for lme4, but it does bring some extra
features/'complications' in the form of the denominator degrees of
freedom.

There are two easy options for getting ANOVA-style p-values:

1. Using lmerTest, you can just do
anova(mod1,ddf="Satterthwaite",type=2) 

If you're using vanilla lme4, then you need to do this first:

library(lmerTest)
mod1 <- as(mod1,"merModLmerTest")

which will cast your model to an lmerTest model.

2. Using the car package:

library(car)
Anova(mod1,test.statistic="F",type=2)

If you fitted your model with maximum likelihood, i.e. with REML=FALSE,
then you need to refit your model using REML first:

mod1 <- update(mod1,REML=TRUE)

For both options, you need to specify the types of test you're doing. I
highly recommend Type 2, but there is a lot of material on that debate,
search for e.g. Venables' "Exegeses on linear models", or look at the
documentation for car::Anova(). Please note that the distinction for
Type 2 vs Type 3 is *very* relevant for your question since you're
concerned about interaction terms.

For the lmerTest route, you can specify the approximation to use for the
denominator degrees of freedom: Satterthwaite is much faster, but
Kenward-Roger is more accurate. For car::Anova(), the F-statistic is
always computed with  Kenward-Roger (and only works for REML-fitted
models for reasons that I can't explain quickly), but you have the
option of using a Chisq test statistic, which is equivalent to assuming
that the denominator degrees of freedom are infinite, or equivalently,
that your t-values for the coefficients are z-values. 

These ANOVA-style tests are Wald tests and are asymptotically equivalent
to the LR-tests, but are less conservative for finite samples. 

Now, since you care about particular contrasts within the model, you may
also just want to look at your model coefficients. Depending on which
coding scheme you're using, the contrasts represented by your model
coefficients might not be the ones you want, but packages like lsmeans
(a regular mention on the list here and very well documented) can
compute all types of contrasts post-hoc. Rereading your question, this
may be the best way to go for your target conclusion/result statements.

Best,
Phillip
On Sat, 2016-06-11 at 16:41 +0000, Sam Hardman [sah74] wrote: