# difference in results of mixed effects model in nlme and lme4 package

Can anyone please tell me why the results of random slope model is different for the same dataset when I use lme and lmer.

I first fitted a random intercept model as follows using both lme as well lmer

mdl1<-lmer(yld.res ~ rain + (1|state),data=data)   #random intercept model using lmer
mdl2<-lme(yld.res ~ rain,random= ~1|state,data=data) #random intercept model using lme

coef(mdl1)
$state (Intercept) rain a -336.4329 0.2711834 b -294.2122 0.2711834 c -256.1548 0.2711834 d -263.4723 0.2711834 e -217.1181 0.2711834 f -239.2984 0.2711834 coef(mdl2) (Intercept) rain a -336.4333 0.2711836 b -294.2125 0.2711836 c -256.1550 0.2711836 d -263.4726 0.2711836 e -217.1183 0.2711836 f -239.2986 0.2711836  As you can see, both of these yield the same results But when I try to fit a random slope model, both give different results: mdl3<-lmer(yld.res ~ rain + (rain|state),data=data) mdl4<-lme(yld.res ~ rain,random= ~rain|state,data=data) coef(mdl3)$state
(Intercept)       rain
a   -124.4119 0.09613782
b   -126.0181 0.11115529
c   -590.5186 0.65422357
d   -334.9604 0.35443209
e   -477.2628 0.61681345
f   -556.7407 0.65785116

coef(mdl4)

(Intercept)        rain
a   -16.09254  0.01476100
b    12.14178 -0.01015262
c  -761.00684  0.83513050
d  -327.16451  0.35018331
e  -451.16396  0.58277976
f  -632.17825  0.74185372


On top of that, when I run mdl3 (random slope using lmer) it gives the following message:

Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
Model failed to converge with max|grad| = 1.30318 (tol = 0.002, component 1)
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?;Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?


I am not sure why is this happening. Which random slope model should I use? The one with lme or lmer?

Which lme4 version are you using? Install the latest if possible. Overly stringent "$False$ "convergence"" warnings were an issue sometimes with some older lmer versions so you might be seeing this.
In addition please check the REML as well as the ML values you are getting. Are they similar or is the one vastly superior than the other? If for instance the log-likelihood of your mdl4 is obviously worse than that of mdl3 you can suspect that something went pretty wrong.
Finally, lme allows you to increase the number of iterations for the EM algorithm used to refine the initial estimates of the random effects variance-covariance coefficients. That can be done using the function lmeControl. Do that, to ensure that your original estimates are more plausible (note: this can lead to significantly larger estimation time).