[R] lme: error message with random=~1

Douglas Bates bates at stat.wisc.edu
Wed Jan 5 13:41:07 CET 2005


Thomas Petzoldt wrote:
> Hello,
> 
> I have an unbalanced mixed model design with two fixed effects
> "site" (2 levels) and "timeOfDay" (4 levels) and two random effects
> "day" (3 consecutive days) and "trap" (6 unique traps, 3 per site).
> 
> The dependent variable is the body length ("BL") of insect larvae from 7 
> to 29 individuals per trap (104 individuals in total).
> 
> To account for pseudo replication I used nlme (or lme4 as suggested for 
> crossed random factors). The results indicate, that the random effects 
> are very small, so I followed the lme example and tried to fit a model 
> with random=~1.
> 
> Unfortunately I got the following error message:
> 
> Error in getGroups.data.frame(dataMix, groups) :
>     Invalid formula for groups
> 
> I suppose, that it would be redundant (and confusing to the reader) if 
> we leave unnecessary random effects in the model, but due to pseudo 
> replication it may be an offense if we simply ignore it and use lm.
> 
> Reading the respective chapters in Pinheiro & Bates, Venables & Ripley 
> and Crawley several times, I found no example for this situation. Is 
> there a common way how to handle this?
> 
> Thomas P.
> 
> PS: I can provide a full example, if necessary.

I'm not sure what model you want to fit here.  To specify a random 
effect in lme you need both a grouping factor and a model matrix.  The 
error message indicates that lme is unable to determine a grouping 
factor.  It would be correct syntax if you added a single level factor 
to the data frame and used that but then the model fit would fail 
because you would be trying to estimate a variance in a model where 
there is no variation in the term.

It seems to me that you are trying to estimate parameters in a 
mixed-effects model without any random effects and lme can't do that.




More information about the R-help mailing list