I have a dataset that consists of students nested within schools. Some of my variables vary across schools but not within them (example: socio-economic index of a school, or region where the school is located), whereas other variables vary across students.
I am applying the following models with the lmer function from R’s lme4 package, but the second model (where I include the variables that don’t vary within schools as random effects) does not converge.
Could you please give me some ideas on how I can deal with this problem?
Model 1: Only the intercept is a random effect
m1 = lmer( english_scores ~ (1| school_id) + school_region + school_linguistic_region + school_socioeconomic + school_size + student_birth + student_gender + student_socioeconomic + student_inmigrant + student_spanish_score + student_maths_score + student_language, data=primary)
Model 2: Both intercept and slopes are random effects
m2 = lmer( english_scores ~ (1 + school_region + school_linguistic_region + school_socioeconomic + school_size | school_id) + school_region + school_linguistic_region + school_socioeconomic + school_size + student_birth + student_gender + student_socioeconomic + student_inmigrant + student_spanish_score + student_maths_score + student_language, data=primary)
I get the following error when I run the second model:
boundary (singular) fit: see help(‘isSingular’) Warning message: Model failed to converge with 2 negative eigenvalues: -3.4e+00 -9.3e+00
I have tried reducing the number of random slopes that I include in the model, thus using:
m2 = lmer( english_scores ~ (1 + school_socioeconomic + school_size | school_id) + school_socioeconomic + school_size + student_birth + student_gender + student_socioeconomic + student_inmigrant + student_spanish_score + student_maths_score + student_language, data=primary)
Still, in this case, I get the following error message:
Warning messages: 1: In checkConv(attr(opt, “derivs”), opt$par, ctrl = control$checkConv, : Model failed to converge with max|grad| = 3.41928 (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?