# Different results in mixed model between R lme(), lmer() and Stata

I am fitting a multilevel model on pooled country-waves, i.e., I ignore the time framework and use individuals nested in countries. However, I obtain different results fitting the starting simple model between lme and lmer

fit1 <- lmer(isei_r ~ fisei + (fisei | country), data = working_age,
REML = FALSE, na.action = na.omit)
fit2 <- lme(isei_r ~ fisei, random = ~ fisei | country, data = working_age,
method = "ML", na.action = na.omit)


Specifically, the first fails to converge, while the second does not show any problem and it's identical to Stata outcome obtained with:

mixed isei_r fisei || country : fisei


I was wondering why is this the case? What is the main difference of lmer() with respect lme() (and/or mixed in Stata framework)?

I add small extract of a simplified dataset with only the variables included here:

 structure(list(country = structure(c(1, 1, 6, 9, 10, 15, 15,
18, 21, 23, 23, 25, 25, 25, 27, 27, 28, 29, 31, 31), label = "Country", labels = c(AT = 1,
BE = 2, BG = 3, CH = 4, CY = 5, CZ = 6, DE = 7, DK = 8, EE = 9,
ES = 10, FI = 11, FR = 12, GB = 13, GR = 14, HR = 15, HU = 16,
IE = 17, IL = 18, IS = 19, IT = 20, LT = 21, LU = 22, LV = 23,
NL = 24, NO = 25, PL = 26, PT = 27, RO = 28, RU = 29, SE = 30,
SI = 31, SK = 32, TR = 33, UA = 34), class = "haven_labelled"),
fisei = structure(c(NA, 46, 55, 29, 70, 21, 69, 23, 16, 70,
37, 29, 30, 34, 16, NA, 32, 32, 41, 34), format.stata = "%10.0g"),
isei_r = structure(c(50.439998626709, 51, 69, 53.8300018310547,
51, 43.1699981689453, 67.6999969482422, 25, 33.2000007629395,
67.6999969482422, 25, 28.8299999237061, 27, 39, 16, NA, 69,
NA, 55.7799987792969, 69), format.stata = "%9.0g"), essround = structure(c(1,
2, 2, 4, 5, 4, 5, 4, 4, 3, 4, 3, 4, 5, 1, 2, 4, 3, 3, 4), label = "ESS round", format.stata = "%12.0g")), row.names = c(NA,
-20L), class = c("tbl_df", "tbl", "data.frame"))

• "fails to converge" may be a false positive. How do the estimates and log-likelihood compare across models? Jun 18, 2020 at 14:42
• between lme() and mixed in Stata they are exactly the same using ML in lme(). The difference is in lmer() that fails to converge. It is -561073.3 for Stata/lme() and -561090.9 for lmer() Jun 18, 2020 at 14:46
• any chance you could share your data so we can see what's going on? Jun 18, 2020 at 15:17
• I'm sorry, what do you mean by [mcve]? Jun 18, 2020 at 15:22
• See here: "You may have been told to include an MCVE – Minimal, Complete, and Verifiable examples is what they were referring to. MCVE was also the former name of the page you're reading now, occasionally misspelled as MVCE, before it was renamed to Minimal, Reproducible Example (sometimes called “reprex”, “min-reprex”, “repro” or just “example”). Jun 18, 2020 at 15:38

It is difficult to see what is going on without a reproducible example. Nonetheless, mixed models are, in general, complex models. And because of this reason, the algorithms used to find the maximum likelihood may some times have trouble converging. Also, note that lmer(), lme() and STATA use different optimization algorithms with different defaults. Hence, is some examples, such as yours, it can happen that one is successful but the other not. In the majority of these cases, tweaking the optimization controls in the algorithm that was unsuccessful resolves the problems. For lmer() in particular have a look in the GLMM FAQ and here.
One reason things might look different across lmer() and mixed is that lmer() (and I think lme()) estimates the covariance between the random slope and random intercept by default. On the other hand, mixed does not. You need to specify it explicitly as such:
 mixed isei_r fisei || country : fisei , cov(unstructured)

See if adding this to your mixed results in estimates that are similar across programs and routines.