9
$\begingroup$

I am fitting a glmer model in the lme4 R package. I'm looking for an anova table with p-value shown therein, but I cannot find any package that fits it. Is it possible to do it in R?

The model I am fitting is of the form:

model1<-glmer(dmn~period*teethTreated+(1|fullName), 
   family="poisson", 
   data=subset(dataset, 
          group=='Four times a year'),
   control=glmerControl(optimizer="bobyqa"))
$\endgroup$

1 Answer 1

9
$\begingroup$

If you're willing to settle for Wald tests this should work:

library(lme4)
library(car)
gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
                   data = cbpp, family = binomial)
Anova(gm1,type="III")

However, note (from ?Anova) that:

The designations "type-II" and "type-III" are borrowed from SAS, but the definitions used here do not correspond precisely to those employed by SAS. Type-II tests are calculated according to the principle of marginality, testing each term after all others, except ignoring the term's higher-order relatives; so-called type-III tests violate marginality, testing each term in the model after all of the others. This definition of Type-II tests corresponds to the tests produced by SAS for analysis-of-variance models, where all of the predictors are factors, but not more generally (i.e., when there are quantitative predictors). Be very careful in formulating the model for type-III tests, or the hypotheses tested will not make sense.

I would check your results very carefully to make sure they make sense!

Alternatively, you can use afex::mixed to get analogous tables via likelihood ratio test or parametric bootstrap; the latter is the most accurate, but also the slowest by far.

See ?pvalues in the lme4 package for more general discussion of p-value computation in the context of GLMMs.

$\endgroup$

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.