3
$\begingroup$

I am running generalised linear mixed effects models in R using the lme4 package. I am wondering if there are any post-hoc tests available for models built using the glmer function?

I know the package lmerTest has a function for post hoc testing lmer models (class merMod), but it won't work for objects of class glmerMod (method given in the lmerTest manual).

My models have either a numeric or integer response variable, two fixed effects (both a factor with 2 levels), and two random effects (both a factor, one nested within the other). I have used either a Gamma (for numeric response) or poisson (for integer response) error family. I want to know which combinations of levels of the fixed effects are statistically different to other combinations.

  1. Are there any options for post hoc testing this type of model?
  2. If not, can anyone recommend another method for performing generalised linear mixed effects models in R that do allow for post hoc testing?

Edit--

The model I am running for ANCOVA analysis is:

m1<-glmer(data=mydata,FLWR_MASS~BASE_MASS*F1TREAT*SO+
    (1 |LINE/MATERNAL_ID),family=Gamma(link=log))

Where FLWR_MASS and BASE_MASS are numeric, and F1TREAT and SO are both factors each with 2 levels.

The code I am using for the post hoc testing of the slope is:

testInteractions(m1, custom=list(F1TREAT='control', SO=c(1,-1),
    slope='BASE_MASS', adjustment="none"))
testInteractions(m1, custom=list(F1TREAT='stress', SO=c(1,-1),
    slope='BASE_MASS', adjustment="none"))
testInteractions(m1, custom=list(SO='s', F1TREAT=c(1,-1),
    slope="BASE_MASS", adjustment="none"))
testInteractions(m1, custom=list(SO='o', F1TREAT=c(1,-1),
    slope="BASE_MASS", adjustment="none")) 

However, as I've mentioned I get the same output regardless of what I specify as the slope (even if it is a term not included in the model)

$\endgroup$
2
$\begingroup$

The functions testInteractions and testFactors in the R package phia allow you to run various post hoc testing through Wald chi-square test. Read this webpage regarding the limitations of the testing strategy.

P.S.:

Is it still valid to use these functions of a model of class glmerMod?

Yes, package phia works fine with glmerMod.

if I have factor 'treat' with levels '1' and '2', and factor 'method' with levels 'a' and 'b', how can I get the comparisons: treat:1 - method:a, treat:1 - method:b, treat:2 - method:a, treat:2 - method:b.

I'm not so sure about the exact comparisons you want to perform. Assuming that the model object is called 'fm', see if the following is what you're looking for:

testInteractions(fm, custom=list(treat='1', method=c(1,-1), adjustment="none")
testInteractions(fm, custom=list(treat='2', method=c(1,-1), adjustment="none")

Can I do the same thing as this, except rather than test for differences in the mean of the response, test for differences in the slope of the response to a covariate?

Suppose your covariate is 'age', do the following:

testInteractions(fm, custom=list(treat='1', method=c(1,-1), slope='age', adjustment="none")
$\endgroup$
  • $\begingroup$ The phia pdf says that currently supported classes fro testInteractions and testFactors include "lm", "glm", "mlm", "lme",and "mer" or "merMod". Is it still valid to use these functions of a model of class glmerMod? Also, how can I use these functions to produce pairwise comparisons of every combination of my two factors. ie, if I have factor 'treat' with levels '1' and '2', and factor 'method' with levels 'a' and 'b', how can I get the comparisons: treat:1 - method:a, treat:1 - method:b, treat:2 - method:a, treat:2 - method:b. $\endgroup$ – Shannon Hodges Sep 10 '14 at 7:19
  • $\begingroup$ I added the answers above in my original response. See if they are good enough. $\endgroup$ – bluepole Sep 10 '14 at 14:48
  • $\begingroup$ Thank you, this was very useful. I just have one more question: Can I do the same thing as this, except rather than test for differences in the mean of the response, test for differences in the slope of the response to a covariate? $\endgroup$ – Shannon Hodges Sep 16 '14 at 5:19
  • $\begingroup$ Check out the added part at the end in my response above. $\endgroup$ – bluepole Sep 16 '14 at 20:36
  • $\begingroup$ Thanks for all your help. I'd love to up vote your answer but don't have the reputation for it yet. $\endgroup$ – Shannon Hodges Sep 19 '14 at 5:03
0
$\begingroup$

I have solved the issue of trying to calculate the differences in the slope. Supposing the covariate is age, @bluepole suggested

testInteractions(fm, custom=list(treat='1', method=c(1,-1),
    slope='age', adjustment="none")

The 'slope' term needs to be placed outside of the 'custom' brackets

Instead:

testInteractions(fm, slope='age', custom=list(treat='1',
    method=c(1,-1)), adjustment="none")

So simple, and yet it took me so long to see it

$\endgroup$
  • $\begingroup$ Sorry about my mistake! Glad that you figured it out... $\endgroup$ – bluepole Sep 30 '14 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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