2
$\begingroup$

I have data for classes that are nested within schools

There are two classes for most schools (n = 240), but I also have some schools with which I have more than two classes. i.e., 20 schools with data from 3 classes, and 4 schools with data from 4 classes.

When I try to run a model like this,

model <- lmer(dv ~ 1 + classmotivation + schoolrep +(1+classmotivation+schoolrep|school/class), data=data)

I get a warning

Warning message:
Model failed to converge with 2 negative eigenvalues: -3.1e+01 -4.0e+02

And I think it's because I don't have enough degrees of freedom to estimate all the random effects,

If I remove either predictor from the random slope like this,

model <- lmer(dv ~ 1 + classmotivation + schoolrep +(1+classmotivation|school/class), data=data)

OR

model <- lmer(dv ~ 1 + classmotivation + schoolrep +(1+schoolrep|school/class), data=data)

the models run. but I'm not sure on what basis I should make such decisions. Is it theoretically-driven or is there something I should know in regard to whether to remove a school-level predictor or class-level predictor from the model (DVs -> class level)

I mean the results don't really change much, but I wasn't sure if I can just remove the slopes like that.

$\endgroup$
  • 2
    $\begingroup$ It is a bit difficult to give suggestions with this little information, anyway you could try to (i) standardize continuous variables; (ii) fit the model setting the random effects correlations to zero (+(1+classmotivation+schoolrep || school/class), note the double |). For choosing which of the random slopes is safer to remove, perhaps you could check the AIC of the two models. Another alternative could be to estimate the model using MCMC, e.g. using Stan and the package bmrs or rstanarm (slower but circumvents convergence warnings) $\endgroup$ – matteo Dec 9 '18 at 20:16
  • $\begingroup$ Please edit the question and post the output from summary(model) $\endgroup$ – Robert Long Dec 10 '18 at 9:21
0
$\begingroup$

As pointed out by matteo in a comment to your question, one possible solution might be to set the random effect correlations to zero through the use of the || operator. However, I would like to point something out regarding your code that is easy to miss.

The use of the / operator in (1 + classmotivation + schoolrep | school/class) is in fact equivalent to writing (1 + classmotivation + schoolrep | school) + (1 + classmotivation + schoolrep | school:class), meaning that you are estimating random slopes, intercepts and their correlations at both the school and class levels. This could be one reason to the non-convergence of the model. Thus, an alternative to dropping random slopes (or the correlations therein) could be to remove the random slopes at one of these levels.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.