[R-sig-ME] Number of random effects error

Leisten, L.M. (Luca) |uc@@|e|@ten @end|ng |rom @tudent@ru@n|
Sat May 22 18:56:29 CEST 2021

Edit: we just figured it out. Our mistake was that our dependent variables were in the df just once for each ID instead of once per row. Thus it resulted in only 172 observations whereas in fact we had more. 

Von: Leisten, L.M. (Luca)
Gesendet: Samstag, 22. Mai 2021 18:13
An: r-sig-mixed-models using r-project.org
Cc: Andriessen, F.J.M. (Fenna)
Betreff: Number of random effects error

​Dear all,​

I am currently working on the data analysis of a project.

Basically our data frame contains 172 IDs, which is our grouping factor, but in total contains 1149 observation from these IDs. We have their weight, and time of measurement in months (that corresponds to their age). We are interested in looking at their weight development over time, thus using their age (which corresponds the the date of their measurement) as a random effect.

Our model structure looks  like this:

model <- lmer(z_WfL ~ c_age_child_month + f_stress + f_education_parent + c_parent_BMI + c_snacking_mean + c_age_child_month:f_stress + c_age_child_month:f_education_parent + c_age_child_month:c_parent_BMI + c_age_child_month:c_snacking_mean + c_age_child_month:f_stress:f_education_parent +  c_age_child_month:f_stress:c_parent_BMI + c_age_child_month:f_stress:c_snacking_mean + (1 + c_age_child_month | id), data = df_cleaned)​

Each child has a different number of observations (between 1 and 16), at different time points (as these correspond to the children's age). When running our model we get the following error:

number of observations (=172) <= number of random effects (=340) for term (1 + c_age_child_month | id); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable​

We already googled it and figured that apparently we are trying to estimate too many random effects and have too little observations for that, but we don't quite understand why, as we have a lot of observations in total. We think the problem probably has to do with our time variable (aka age), as this can either be put in unrounded (so very different for most children), or rounded (which results in multiple measures on the same age per id).

We would really appreciate any help on this!


Luca & Fenna

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