2
$\begingroup$

I want to evaluate the effect of number of flowers (fixed effect) and soil nutritional content (fixed effect) on size of flower. The experimental design consists in 16 plants growing on two substrates (8 plants per substrate). I have more than one observation per plant for the size and number of flower and a unique observation of the soil nutritional content per plant. So, as the type of substrate influences the nutritional content and in some cases, I have more than one observation per plant, I put in the model substrate and plant nested in substrate as random effects.

However, when I tried to fit this model in R using the lme4 package, I received this error:

Error: number of levels of each grouping factor must be < number of observations

I believe this means that the random effects are not identified, but I have repeated measurements, so what could be wrong here ?

$\endgroup$
5
  • 2
    $\begingroup$ I have re-written this question to make it about a statistical issue, rather than a software one and thus I am voting to re-open it. $\endgroup$ Commented May 22, 2019 at 11:15
  • $\begingroup$ This still reads as a programming or data-related error, though. And one that's hard to address without knowing more about the data and model. $\endgroup$
    – mkt
    Commented May 22, 2019 at 11:57
  • 1
    $\begingroup$ @mkt I disagree. I think they have provided enough information to answer. I would be shocked if this was posted as a question in its current form and it was closed as off topic. $\endgroup$ Commented May 22, 2019 at 13:13
  • $\begingroup$ Could you please post the call you made to the mixed-effect modeling program? Also, just how many individual observations are there on flower size for each combination of covariates? It's possible that there are more combinations of random slopes and random intercepts than the number of observations will allow (despite the multiple observations per plant). A proper answer would require knowing that information. $\endgroup$
    – EdM
    Commented May 22, 2019 at 17:16
  • $\begingroup$ @EdM they don't mention random slopes but they do say that "in some cases, I have more than one observation per plant" so there are multiple single observations per plant, and since they also specify plants nested in substrates, which has only 2 levels, I think the problem lies there. $\endgroup$ Commented May 22, 2019 at 19:14

1 Answer 1

3
$\begingroup$

Since you say that plant is nested within substrate it appears that you are fitting random effects (random intercepts) for substrate, which has 2 levels and the substrate:plant interaction (32 levels),

So, if you have fewer than 34 observations in total, then you will receive the error that you quoted.

The solution is to remove substrate from the random structure. This is indicated not only as a solution to this problem, but since there are only 2 levels of it, by specifying random intercepts for it you are asking the software to compute a variance for something that has only 2 observations, which doesn't make a lot of sense. Instead, fit substrate as a fixed effect/confounder, so your model should look something like

FlowerSize ~ NumFlowers + Nutr + Substrate + (1|PlantID)
$\endgroup$
1
  • $\begingroup$ I have already resolved the issue, the problema was some cells was empty. Since I dont have the same number of observations for all variables. thank for the answers $\endgroup$
    – AnahíF
    Commented May 23, 2019 at 13:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.