# [R-sig-ME] convergence issues on lme4 and incoherent error messages

René b|mono@om @end|ng |rom gm@||@com
Fri Jun 14 11:08:53 CEST 2019

```Ah now I think of the following:
Estimating by-subject random slopes necessarily requires that the random
slope (i.e. in all within-subject design cells) is measured on each
subject. If, as you say, there are measurements missing in some
design-cells for some subjects, then, actually, estimating the variance of
fixed effects between subjects (just another word for by-subject random
slopes) becomes partially the same as measuring the fixed effect itself,
which is 'bad'.  Furthermore, this might be similarly troubling when
estimating by-subject intercepts, but for a slightly different reason,
namely, (lets make it extreme) if half of the subjects have measures in all
design cells, while the other half has only measures in some-design cells,
then what would you expect how the intercepts are distributed (i.e. the
subjects average response deviation from the grand mean), if there are
systematic differences between the means in the design-cells? The a priori
answer is, "probably not Gaussian", which is again 'bad'  :))

I would suggest to adjust the model-definition to reflect the fact that
there are cell-measurements missing for some subjects (regardless of
whether a model converges or not, but just because, this would be the only
way to meaningfully interpret the model).
I think this should work:
Let's take the model from the last link you posted

cc_marg ~ mPair*spd_des + diag(mPair:spd_des|ratID)

Define a (-numeric-) variable (say "cell_exists") in the data frame which
codes whether a subject (for all observations by that subject) has
measurements in all cells (coded as 1), or not (coded as 0), such that all
subjects of which you speak have missing data in some cells are 0.
Then:

cc_marg ~ mPair*spd_des + diag(0+cell_exists:mPair:spd_des|ratID)

Will estimate (no intercepts and) only random slopes for subjects with
cell_exists=1
And to achieve the same for intercept (lets have a second variable which is
identically coded as cell_exists to be as clear as possible:
cell_exists_intercept)

cc_marg ~ mPair*spd_des + diag(0+ cell_exists_intercept
+cell_exists:mPair:spd_des|ratID)

And the intercept then would be the "cell_exists_intercept".
This should deal with the missing stuff :)
But don't ask me how to call the random effects in the end :)) (random
slopes for a sub-sample of subjects maybe), or the residuals (mixture
between individual level model errors, and random intercept and slope
variance for those subjects with incomplete data).

Hope this helps (I guess there will be a solution eventually, there is not
much left to do, except going Bayesian :))
Best, René

Am Fr., 14. Juni 2019 um 03:36 Uhr schrieb David Duffy <
David.Duffy using qimrberghofer.edu.au>:

> FWIW, on my machine,
>
> lmer(cc_marg ~  mPair*spd_des + (1|cycle) + (1|ratID), data=dat)
>
> runs without complaint. It's only when I add in mPair as fixed and random
> that I get problems. I notice that cycle has a *lot* of levels,and the
> distribution of cc_marg is pretty skewed. I always have trouble
> understanding measurement models in a lmer formula - mPair are six
> different measures, is that right? If that is the case, you might
> cross-check your results by running in MCMCglmm as an explicit multivariate
> model, and getting the same answers.
>
> Cheers, David Duffy.
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

[[alternative HTML version deleted]]

```