1
$\begingroup$

I run

ModelOne <- lm(OneMilkProd~  RobotsPen+FreshGroup+RobotFeeds+LiquidFeed,  data = FarmAVG)

but was suggested to include farm as a random effect.

There is 1 farm per OneMilkProd, and each farm has its own variation of RobotsPen + FreshGroup + RobotFeeds + LiquidFeed

When I make the model LMER

ModelOne <- lmer (OneMilkProd~  RobotsPen+FreshGroup+RobotFeeds+LiquidFeed + (1\Farm) ,  data = FarmAVG)
Error: number of levels of each grouping factor must be < number of observations (problems: Farm)

I receive the error above. I tried making the argument that 1 observation per response is not enough for a random effect.

All predictors are categorical and the response is continuous

$\endgroup$
1
  • $\begingroup$ Isn't the message self-explaining? You have a too complex model for your data $\endgroup$ Commented Jul 23, 2021 at 15:24

1 Answer 1

2
$\begingroup$

We typically fit random intercepts when we have repeated measures or some other kind of clustering within levels of a grouping variable.

From the description in the OP it seems that you have one observations per farm, so you don't have repeated measures within farms, and that is what is causing the error.

$\endgroup$
0

Your Answer

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

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