[R-sig-ME] lmList from lme4 on grouped data objects

Viechtbauer Wolfgang (STAT) wolfgang.viechtbauer at maastrichtuniversity.nl
Tue Nov 12 09:54:39 CET 2013


Dear lme4-Maintainers,

As far as I can tell, lmList() from lme4 does not play nicely with grouped data objects from the nlme package. Example:

library(lme4)
data(Orthodont, package="nlme")

class(Orthodont)

### [1] "nfnGroupedData" "nfGroupedData"  "groupedData"    "data.frame"

res <- lmList(distance ~ age | Subject, data=Orthodont)

### Error in eval(expr, envir, enclos) : object 'Subject' not found
### In addition: Warning message:
### In Ops.ordered(age, Subject) : '|' is not meaningful for ordered factors

Orthodont <- as.data.frame(Orthodont)

res <- lmList(distance ~ age | Subject, data=Orthodont)

### works

This had me stumped for a while, so I figured I would note this here (in case anybody else runs into this issue). After googling a bit, I found:

https://github.com/lme4/lme4/blob/master/tests/lmList.R

so nothing really new here. But maybe add a check to lmList() whether somebody specifies a grouped data object and turn it into a regular data frame?

Best,
Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   



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