[R-sig-ME] model specification in lmer

Voeten, C.C. c.c.voeten at hum.leidenuniv.nl
Thu Nov 30 21:26:59 CET 2017


There are various ways to do this. The most important thing to make sure of is that the models you're comparing are both fitted either with or without REML; you can't mix ML and REML fits (that will heavily bias your LRT in favor of the ML model). You can fit the no-random-intercept model using lm(), and use anova() to compare it with a random-intercept lmer model fitted with REML=F. A (perhaps slightly better) alternative is to use gls() from nlme to fit the no-random-intercept model using REML. You can then manually calculate chi-square values like so:

> library(nlme)
> library(lme4)
Loading required package: Matrix

Attaching package: ‘lme4’

The following object is masked from ‘package:nlme’:

    lmList

> model1 <- gls(Reaction~Days,sleepstudy)
> model2 <- lmer(Reaction~Days + (1|Subject),sleepstudy)
> ( neg2ll1 <- -2*logLik(model1) )
'log Lik.' 1893.664 (df=3)
> ( neg2ll2 <- -2*logLik(model2) )
'log Lik.' 1786.465 (df=4)
> ( difference <- as.numeric(neg2ll2-neg2ll1) )
[1] -107.1986
> pchisq(difference,1)
[1] 0

Good luck!
________________________________________
Van: R-sig-mixed-models [r-sig-mixed-models-bounces at r-project.org] namens silvia.matesanzgarcia at gmail.com [silvia.matesanzgarcia at gmail.com]
Verzonden: donderdag 30 november 2017 19:55
Aan: r-sig-mixed-models at r-project.org
Onderwerp: [R-sig-ME] model specification in lmer

Hello all

I am attempting to fit a mixed model in lmer. I have an experimental design
with families nested within populations in two different treatments, and I
want to test the effects of Pop, Trt, and Pop:Trt as fixed factors, and
Family and Family*Trt as random factors.



My full model would be:

model1=lmer(Trait~Pop*Trt + (Trt|Family)

I can then use:

model2=lmer(Trait~Pop*Trt + (1|Family)

and

anova(model1, model2) would provide signification for the interaction term.



I would need a third model with only the interaction term, so that I can
compare it to the full model and obtain significance for the family term.
But I can't figure out how to do this last part.



Can I just compare model2 to a model with no random part?



Thank you so much for your help in advance.




        [[alternative HTML version deleted]]

_______________________________________________
R-sig-mixed-models at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



More information about the R-sig-mixed-models mailing list