I have a dataset that I want to model with a single response variable (yield of a crop plant). However, I have multiple replicates of my proposed predictor variables, from multiple sampling surveys of visiting insect pollinators for each plant.

Is it possible to model yield without averaging the predictor variables by plant? The only way I see to do this is to have repeated entries of the same response measurement for each plant, in order to match the number of survey repetitions for each plant. However, we were not able to conduct insect surveys on each plant for the same number of times due to logistical reasons.

It seems like I would be losing information if I just averaged the predictor variable values for each plant, but on the other hand, inflating the number of responses to match the number of insect surveys would place more weight on plants with more surveys (I think).

Is there a recommended approach for dealing with this situation? Is this addressed by adding the plant ID as a random effect?


1 Answer 1


Yes, you are correct, that averaging the measurements for each plant is a bad idea as it loses important information.

And again, you are correct that a mixed effects model can, in principle, be used, by fitting random intercepts for plant ID. In lme4 (and several other packages) in R, you could specify this as

lmer(yield ~ predictors + (1 | plantID) 

This will control for the repeated measurements and also handle the unbalanced design.

Depending on the data (and your research hypotheses) you can also allow the effect of predictors to differ for each plant, by specifying random slopes for the predictors.

  • $\begingroup$ Thanks for your response. How would this extend to more than 1 predictor if they were collected with independent surveys? Does this mean that I would need to have all possible combinations of replicates from each predictor for each response, e.g. if each plant (response) has associated with it 5 insect surveys and 3 vegetation surveys (taken independently), then this becomes 15 entries where each of the 5 insect surveys is combined with one of the 3 vegetation survey results in turn? $\endgroup$
    – K Li
    May 16, 2019 at 12:06
  • 1
    $\begingroup$ It is not clear to me exactly how your sampling scheme is set up, but mixed models don't require all possible combinations of the levels of different predictors. That is now a different but related question, so it would be better for future visitors to the site if you can ask a separate question (and include more details about how your sampling is done and perhaps include some example data). If you think that this answer answers you original question, please consider marking it as the accepted answer. $\endgroup$ May 16, 2019 at 13:33
  • 1
    $\begingroup$ Sorry my previous comment wasn't clearly worded. By "need", I didn't mean to suggest a change in study design - just how the dataset is organized for analysis. I agree this question would be clearer with example data, and if you think it's a separate question now, I will make a new question. $\endgroup$
    – K Li
    May 17, 2019 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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