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?
The problematic model:
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)
..has random slopes for:
school_region
school_linguistic_region
school_socioeconomic
school_size
Since none of these vary within schools, then specifying them as random slopes within school does not make any sense, and is very likely the cause of the convergence problem.
Could you please give me some ideas on how I can deal with this problem?
Yes, don't fit random slopes for these variables. Random slopes should be used for variables that have variation within the grouping factor (in this case, schools)
Your initial model:
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)
..should do just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With