[R-sig-ME] random effects specification

Douglas Bates bates at stat.wisc.edu
Fri Apr 4 00:32:40 CEST 2008


On Thu, Apr 3, 2008 at 3:45 PM, Sebastian P. Luque <spluque at gmail.com> wrote:
> Hi,

>  In the past I've used lme to fit simple mixed models to longitudinal
>  data (growth), but now I'm trying to learn lmer and its different syntax
>  to fit a more complex model.  I have a structure with subjects (id,
>  random factor) exposed to 4 different treatments and a continuous
>  response variable is measured (n).  The subjects come from 2 different
>  communities, so it's a nested design very much like the Oats data in the
>  nlme package.  The interest is in the fixed effects of community and
>  treatment, and their interaction, so I thought this could be modelled in
>  lmer with this call:

>  lmer(n ~ treatment + community + (1 | id/treatment), mydata)

>  but got this error:

>  Error in lmerFactorList(formula, mf, fltype) :
>   number of levels in grouping factor(s) 'treatment:id' is too large

>  Am I using the right formula here?  Thanks.

It seems that the observations are indexed by subject and treatment so
the number of levels in the factor treatment:id equals the number of
observations.  You can't estimate a variance for such a term and also
estimate a residual variance.

I would start with

n ~ treatment * community +(1|id)




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