0

I am trying to analyze some simulated data (long data format) of 199 participants using the lme4 package. In this dataset, belongingness, authenticity, and inclusion are measured two times and are predicted by exercise condition (= 0, 1, 2), Time (= 0, 1), and population (=0, 1). For this, I fitted the following three models to the data:

ModelH2 = lmer(Belongingness ~ 1 + Exercise*Time + (1 + Time|id), REML=F, data=inclusion_data)

ModelH3 = lmer(Authenticity ~ 1 + Exercise*Time + (1 + Time|id), REML=F, data=inclusion_data)

ModelH4_H5 = lmer(Inclusion~ 1 + Exercise*Time + Population*Time + (1 + Time|id ), REML=F, data=inclusion_data)

However, when I try to fit these three models, I get the following error

Error: number of observations (=398) <= number of random effects (=398) for term (1 + Time | id); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable

I read some suggestions on StackOverflow that it could help to change (1 + Time | id) to (Time | id) but did not help, I still received the same error.

Can you help me solve this error?

  • 1
    The error is saying that the random effect (id) has the same number of values as you have rows in your data, do you only have unique id values in your whole data set? – user2974951 Jan 28 '20 at 12:38
  • @user2974951 I think so. In the (participant) id row, the numbers range from 1 to 199 but in the long format of the data each participant has two rows (for the two measurement moments, Time=1 and Time=2). So it goes like 1 1 2 2 etc. – Benson van der Bij Jan 28 '20 at 12:54
  • You really do not have enough data to estimate random effects, try `(1|id)`, maybe that will work. – user2974951 Jan 28 '20 at 12:58
  • @user2974951 that works but is however not my hypothesized model. How much data do I need to have to estimate random effects? Shouldn't this be possible to estimate with any sample size? – Benson van der Bij Jan 28 '20 at 13:03
  • Estimating random effects does depend on the size of your data (number of data points per group). I think you need at least 3 points to estimate a slope. But even then, you will have so few data points that it will be very variable. Conclusion -> you need more data if you want to estimate your model. – user2974951 Jan 28 '20 at 13:14
  • I get what you mean, so In order to estimate the random of time, I should have at least 3 measurement moments of inclusion, authenticity, and belongingness per participant? – Benson van der Bij Jan 28 '20 at 13:22
  • Try it out, generate a new random row for each participant (Time=3) and see if the model builds. – user2974951 Jan 28 '20 at 13:31
  • If I have 3 points to estimate the slope per participant, I can fit the model indeed but then I receive the warning message: `In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model failed to converge with max|grad| = 0.00496002 (tol = 0.002, component 1)` – Benson van der Bij Jan 28 '20 at 14:21
  • This may or may not be because you generated the new data randomly, which can cause problems for the convergence of the optimizer. In which case you can try increasing the maximum number of iterations or changing the optimizer. But to be safe, you should have more than 3 points. – user2974951 Jan 28 '20 at 14:24
  • Thanks for your advice! I will try to fit the models on the real data in a few months, maybe that solves my issue then. However, I was wondering still what you mean with the optimizer? – Benson van der Bij Jan 28 '20 at 14:59
  • If you check the manual you will find a lmerControl argument in the lmer function, which first argument selects the optimizer (Nelder_Mead and bobyqa). – user2974951 Jan 29 '20 at 09:41
  • Great, thanks for all your help! – Benson van der Bij Jan 29 '20 at 12:53

1 Answers1

0

user2974951 explained me this error (which prevented me from fitting my models)) in the comments section of the question.

He explained that the error is saying that the random effect (id) has the same number of values as I have rows in your data and that I do not have enough data points per participant to estimate random effects.

When I made a simulated dataset with three data points per participant, I could fit the model but received the error regarding convergence of the optimizer. For more information on the optimizer, user2974951 referred to the manual on the lmerControl argument in the lmer function.