Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare a model with no random effects to a model with a random effect using lme4?

Tags:

I can use gls() from the nlme package to build mod1 with no random effects. I can then compare mod1 using AIC to mod2 built using lme() which does include a random effect.

mod1 = gls(response ~ fixed1 + fixed2, method="REML", data) mod2 = lme(response ~ fixed1 + fixed2, random = ~1 | random1, method="REML",data) AIC(mod1,mod2) 

Is there something similar to gls() for the lme4 package which would allow me to build mod3 with no random effects and compare it to mod4 built using lmer() which does include a random effect?

mod3 = ???(response ~ fixed1 + fixed2, REML=T, data) mod4 = lmer(response ~ fixed1 + fixed2 + (1|random1), REML=T, data) AIC(mod3,mod4) 
like image 499
It Figures Avatar asked Jun 03 '14 16:06

It Figures


People also ask

What is the difference between fixed effect model and random effect model?

The fixed-effects model assumes that the individual-specific effect is correlated to the independent variable. The random-effects model allows making inferences on the population data based on the assumption of normal distribution.

How do you choose between fixed effects and random effects?

The most important practical difference between the two is this: Random effects are estimated with partial pooling, while fixed effects are not. Partial pooling means that, if you have few data points in a group, the group's effect estimate will be based partially on the more abundant data from other groups.

When should you use a random effects model?

If the study effect sizes are seen as having been sampled from a distribution of effect sizes, then the random-effects model, which reflects this idea, is the logical one to use. If the between-studies variance is substantial (and statistically significant) then the fixed-effect model is inappropriate.

What is the main assumption of a random effects model?

The random effects assumption (made in a random effects model) is that the individual specific effects are uncorrelated with the independent variables. The fixed effect assumption is that the individual specific effect is correlated with the independent variables.


1 Answers

With modern (>1.0) versions of lme4 you can make a direct comparison between lmer fits and the corresponding lm model, but you have to use ML --- it's hard to come up with a sensible analogue of the "REML criterion" for a model without random effects (because it would involve a linear transformation of the data that set all of the fixed effects to zero ...)

You should be aware that there are theoretical issues with information-theoretic comparisons between models with and without variance components: see the GLMM FAQ for more information.

library(lme4) fm1 <- lmer(Reaction~Days+(1|Subject),sleepstudy, REML=FALSE) fm0 <- lm(Reaction~Days,sleepstudy) AIC(fm1,fm0) ##     df      AIC ## fm1  4 1802.079 ## fm0  3 1906.293 

I prefer output in this format (delta-AIC rather than raw AIC values):

bbmle::AICtab(fm1,fm0) ##     dAIC  df ## fm1   0.0 4  ## fm0 104.2 3  

To test, let's simulate data with no random effect (I had to try a couple of random-number seeds to get an example where the among-subject std dev was actually estimated as zero):

rr <- simulate(~Days+(1|Subject),                newparams=list(theta=0,beta=fixef(fm1),                          sigma=sigma(fm1)),                newdata=sleepstudy,                family="gaussian",                seed=103)[[1]] ss <- transform(sleepstudy,Reaction=rr) fm1Z <- update(fm1,data=ss) VarCorr(fm1Z) ##  Groups   Name        Std.Dev. ##  Subject  (Intercept)  0.000   ##  Residual             29.241 fm0Z <- update(fm0,data=ss) all.equal(c(logLik(fm0Z)),c(logLik(fm1Z)))  ## TRUE 
like image 190
Ben Bolker Avatar answered Oct 27 '22 04:10

Ben Bolker