Skip to content
Prev 18754 / 20628 Next

Dropping correlations bet. random-effects in lme4 syntax

On 03/10/2020 19:24, Simon Harmel wrote:
Yes, by default R adds in an intercept. I recommend always writing 1+ or
0+ to make explicit what you want.

(This was what I meant with "Note that life gets tricky with the
interaction terms." in my first reply.)
Singularity isn't a problem per se -- it's mathematically well defined
and being able to fit singular covariance matrices for the random
effects was one of the algorithmic innovations lme4 has compared to its
predecessor nlme.

Singularity can be a problem for inference (because it's often a sign of
overfitting).... but it makes sense here. B has no correlation with the
first intercept because you set it to be zero via your formula
specification, so that term is forced to be zero in the model
computation. The second intercept is perfectly correlated with B because
it (the second intercept) is redundant in the model, but it can't
correlate with the first intercept (because that correlation is forced
to zero by your model specification) and so it collapses into B.

If B is continuous, you can avoid this with 0+B. If B is categorical,
then 0+B will still be overparameterized, but you can try 0+dummy(B) to
set up indicator variable for one of the two levels. (I can tell from
your output that B is continuous or only has two levels because there is
only one slope for it.)

Phillip