I have fitted a GLMM with the function glmer of lme4 package. My data consists of a repeated measures count variable, which I am trying to explain with a continuous variable (week) and some categorical variables (zone, treatment and plot). The plot variable I used as a random factor, since I cannot tell the influence of plot itself.
Here is a subset of my data set, which provides the same error messages as the whole set:
plot date total_no zone treatment week fzone
3 110 2019-03-28 137 pioneer ambient 3 pioneer
4 110 2019-04-04 187 pioneer ambient 4 pioneer
5 110 2019-04-11 200 pioneer ambient 5 pioneer
6 110 2019-04-18 203 pioneer ambient 6 pioneer
7 110 2019-04-25 177 pioneer ambient 7 pioneer
8 110 2019-05-02 123 pioneer ambient 8 pioneer
9 110 2019-05-09 122 pioneer ambient 9 pioneer
10 110 2019-05-16 123 pioneer ambient 10 pioneer
11 110 2019-05-24 123 pioneer ambient 11 pioneer
23 111 2019-03-28 122 pioneer +1.5 3 pioneer
24 111 2019-04-04 153 pioneer +1.5 4 pioneer
25 111 2019-04-11 136 pioneer +1.5 5 pioneer
26 111 2019-04-18 145 pioneer +1.5 6 pioneer
27 111 2019-04-25 110 pioneer +1.5 7 pioneer
28 111 2019-05-02 65 pioneer +1.5 8 pioneer
29 111 2019-05-09 89 pioneer +1.5 9 pioneer
30 111 2019-05-16 79 pioneer +1.5 10 pioneer
31 111 2019-05-24 54 pioneer +1.5 11 pioneer
43 112 2019-03-28 89 pioneer +3 3 pioneer
44 112 2019-04-04 101 pioneer +3 4 pioneer
45 112 2019-04-11 104 pioneer +3 5 pioneer
46 112 2019-04-18 95 pioneer +3 6 pioneer
47 112 2019-04-25 110 pioneer +3 7 pioneer
48 112 2019-05-02 88 pioneer +3 8 pioneer
49 112 2019-05-09 89 pioneer +3 9 pioneer
50 112 2019-05-16 98 pioneer +3 10 pioneer
51 112 2019-05-24 99 pioneer +3 11 pioneer
63 120 2019-03-28 77 pioneer ambient 3 pioneer
64 120 2019-04-04 104 pioneer ambient 4 pioneer
65 120 2019-04-11 107 pioneer ambient 5 pioneer
66 120 2019-04-18 131 pioneer ambient 6 pioneer
67 120 2019-04-25 171 pioneer ambient 7 pioneer
68 120 2019-05-02 89 pioneer ambient 8 pioneer
69 120 2019-05-09 94 pioneer ambient 9 pioneer
70 120 2019-05-16 66 pioneer ambient 10 pioneer
71 120 2019-05-24 63 pioneer ambient 11 pioneer
83 121 2019-03-28 23 pioneer +1.5 3 pioneer
84 121 2019-04-04 47 pioneer +1.5 4 pioneer
85 121 2019-04-11 63 pioneer +1.5 5 pioneer
86 121 2019-04-18 52 pioneer +1.5 6 pioneer
87 121 2019-04-25 54 pioneer +1.5 7 pioneer
88 121 2019-05-02 46 pioneer +1.5 8 pioneer
89 121 2019-05-09 43 pioneer +1.5 9 pioneer
90 121 2019-05-16 46 pioneer +1.5 10 pioneer
91 121 2019-05-24 44 pioneer +1.5 11 pioneer
103 122 2019-03-28 85 pioneer +3 3 pioneer
104 122 2019-04-04 109 pioneer +3 4 pioneer
105 122 2019-04-11 126 pioneer +3 5 pioneer
106 122 2019-04-18 110 pioneer +3 6 pioneer
107 122 2019-04-25 113 pioneer +3 7 pioneer
108 122 2019-05-02 97 pioneer +3 8 pioneer
109 122 2019-05-09 89 pioneer +3 9 pioneer
110 122 2019-05-16 74 pioneer +3 10 pioneer
111 122 2019-05-24 95 pioneer +3 11 pioneer
123 130 2019-03-28 62 pioneer ambient 3 pioneer
124 130 2019-04-04 64 pioneer ambient 4 pioneer
125 130 2019-04-11 75 pioneer ambient 5 pioneer
126 130 2019-04-18 58 pioneer ambient 6 pioneer
127 130 2019-04-25 60 pioneer ambient 7 pioneer
128 130 2019-05-02 47 pioneer ambient 8 pioneer
129 130 2019-05-09 86 pioneer ambient 9 pioneer
130 130 2019-05-16 72 pioneer ambient 10 pioneer
131 130 2019-05-24 69 pioneer ambient 11 pioneer
143 131 2019-03-28 233 pioneer +1.5 3 pioneer
144 131 2019-04-04 277 pioneer +1.5 4 pioneer
145 131 2019-04-11 303 pioneer +1.5 5 pioneer
146 131 2019-04-18 281 pioneer +1.5 6 pioneer
147 131 2019-04-25 216 pioneer +1.5 7 pioneer
148 131 2019-05-02 202 pioneer +1.5 8 pioneer
149 131 2019-05-09 197 pioneer +1.5 9 pioneer
150 131 2019-05-16 144 pioneer +1.5 10 pioneer
151 131 2019-05-24 167 pioneer +1.5 11 pioneer
163 132 2019-03-28 170 pioneer +3 3 pioneer
164 132 2019-04-04 211 pioneer +3 4 pioneer
165 132 2019-04-11 323 pioneer +3 5 pioneer
166 132 2019-04-18 298 pioneer +3 6 pioneer
167 132 2019-04-25 297 pioneer +3 7 pioneer
168 132 2019-05-02 212 pioneer +3 8 pioneer
169 132 2019-05-09 202 pioneer +3 9 pioneer
170 132 2019-05-16 204 pioneer +3 10 pioneer
171 132 2019-05-24 215 pioneer +3 11 pioneer
183 240 2019-03-28 9 lowmarsh ambient 3 lowmarsh
184 240 2019-04-04 16 lowmarsh ambient 4 lowmarsh
185 240 2019-04-11 8 lowmarsh ambient 5 lowmarsh
186 240 2019-04-18 8 lowmarsh ambient 6 lowmarsh
187 240 2019-04-25 8 lowmarsh ambient 7 lowmarsh
188 240 2019-05-02 8 lowmarsh ambient 8 lowmarsh
189 240 2019-05-09 11 lowmarsh ambient 9 lowmarsh
190 240 2019-05-16 12 lowmarsh ambient 10 lowmarsh
191 240 2019-05-24 11 lowmarsh ambient 11 lowmarsh
203 241 2019-03-28 9 lowmarsh +1.5 3 lowmarsh
204 241 2019-04-04 20 lowmarsh +1.5 4 lowmarsh
205 241 2019-04-11 19 lowmarsh +1.5 5 lowmarsh
206 241 2019-04-18 15 lowmarsh +1.5 6 lowmarsh
207 241 2019-04-25 21 lowmarsh +1.5 7 lowmarsh
208 241 2019-05-02 19 lowmarsh +1.5 8 lowmarsh
209 241 2019-05-09 21 lowmarsh +1.5 9 lowmarsh
210 241 2019-05-16 14 lowmarsh +1.5 10 lowmarsh
211 241 2019-05-24 17 lowmarsh +1.5 11 lowmarsh
223 242 2019-03-28 17 lowmarsh +3 3 lowmarsh
224 242 2019-04-04 22 lowmarsh +3 4 lowmarsh
225 242 2019-04-11 28 lowmarsh +3 5 lowmarsh
226 242 2019-04-18 26 lowmarsh +3 6 lowmarsh
227 242 2019-04-25 25 lowmarsh +3 7 lowmarsh
228 242 2019-05-02 15 lowmarsh +3 8 lowmarsh
229 242 2019-05-09 14 lowmarsh +3 9 lowmarsh
230 242 2019-05-16 17 lowmarsh +3 10 lowmarsh
231 242 2019-05-24 14 lowmarsh +3 11 lowmarsh
243 250 2019-03-28 53 lowmarsh ambient 3 lowmarsh
244 250 2019-04-04 55 lowmarsh ambient 4 lowmarsh
245 250 2019-04-11 66 lowmarsh ambient 5 lowmarsh
246 250 2019-04-18 64 lowmarsh ambient 6 lowmarsh
247 250 2019-04-25 19 lowmarsh ambient 7 lowmarsh
248 250 2019-05-02 11 lowmarsh ambient 8 lowmarsh
249 250 2019-05-09 60 lowmarsh ambient 9 lowmarsh
250 250 2019-05-16 66 lowmarsh ambient 10 lowmarsh
251 250 2019-05-24 50 lowmarsh ambient 11 lowmarsh
263 251 2019-03-28 11 lowmarsh +1.5 3 lowmarsh
264 251 2019-04-04 20 lowmarsh +1.5 4 lowmarsh
265 251 2019-04-11 21 lowmarsh +1.5 5 lowmarsh
266 251 2019-04-18 13 lowmarsh +1.5 6 lowmarsh
267 251 2019-04-25 12 lowmarsh +1.5 7 lowmarsh
268 251 2019-05-02 62 lowmarsh +1.5 8 lowmarsh
269 251 2019-05-09 11 lowmarsh +1.5 9 lowmarsh
270 251 2019-05-16 12 lowmarsh +1.5 10 lowmarsh
271 251 2019-05-24 13 lowmarsh +1.5 11 lowmarsh
283 252 2019-03-28 18 lowmarsh +3 3 lowmarsh
284 252 2019-04-04 29 lowmarsh +3 4 lowmarsh
285 252 2019-04-11 50 lowmarsh +3 5 lowmarsh
286 252 2019-04-18 43 lowmarsh +3 6 lowmarsh
287 252 2019-04-25 47 lowmarsh +3 7 lowmarsh
288 252 2019-05-02 12 lowmarsh +3 8 lowmarsh
289 252 2019-05-09 15 lowmarsh +3 9 lowmarsh
290 252 2019-05-16 20 lowmarsh +3 10 lowmarsh
291 252 2019-05-24 29 lowmarsh +3 11 lowmarsh
303 260 2019-03-28 6 lowmarsh ambient 3 lowmarsh
304 260 2019-04-04 14 lowmarsh ambient 4 lowmarsh
305 260 2019-04-11 15 lowmarsh ambient 5 lowmarsh
306 260 2019-04-18 10 lowmarsh ambient 6 lowmarsh
307 260 2019-04-25 10 lowmarsh ambient 7 lowmarsh
308 260 2019-05-02 11 lowmarsh ambient 8 lowmarsh
309 260 2019-05-09 11 lowmarsh ambient 9 lowmarsh
I implemented this model
glmm.a<-glmer(total_no~week*treatment*fzone+(1|plot), data=subset,
family=poisson
)
Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge with max|grad| = 0.00689502 (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?;Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?
I got these warning messages above, which I researched can be solved in come cases by using different optimizers, so I did this:
glmm.1<-glmer(total_no~week*treatment+fzone+(1|plot), data=subset,
family=poisson, control=glmerControl(optimizer=c("bobyqa","Nelder_Mead"),optCtrl=list(maxfun=100000))
)
I still get the same warnings. Then I simplified the model, because one interaction had no significance at all (is this allowed, when such warning messages occur, or do I have to have a model to begin with, which has no warnings?)
glmm.1<-glmer(total_no~week*treatment+fzone+(1|plot), data=subset,
family=poisson,
control=glmerControl(optimizer=c("bobyqa","Nelder_Mead"),optCtrl=list(maxfun=100000))
)
The model outputs look like this:
Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) [glmerMod]
Family: poisson ( log )
Formula: total_no ~ week * treatment * fzone + (1 | plot)
Data: subset
Control:
glmerControl(optimizer = c("bobyqa", "Nelder_Mead"), optCtrl = list(maxfun = 1e+05))
AIC BIC logLik deviance df.resid
3312.7 3388.7 -1637.3 3274.7 386
Scaled residuals:
Min 1Q Median 3Q Max
-6.9475 -1.0915 -0.0573 0.9091 12.2790
Random effects:
Groups Name Variance Std.Dev.
plot (Intercept) 0.2371 0.4869
Number of obs: 405, groups: plot, 27
Fixed effects:
Estimate Std. Error z value
(Intercept) 1.553798 0.331032 4.694
week -0.052487 0.015483 -3.390
treatment+3 -0.120870 0.452937 -0.267
treatmentambient 0.375292 0.428522 0.876
fzonelowmarsh 1.829767 0.443244 4.128
fzonepioneer 3.614629 0.435442 8.301
week:treatment+3 -0.002754 0.023291 -0.118
week:treatmentambient -0.038247 0.021971 -1.741
week:fzonelowmarsh -0.051666 0.018045 -2.863
week:fzonepioneer -0.028577 0.015761 -1.813
treatment+3:fzonelowmarsh 0.358579 0.613986 0.584
treatmentambient:fzonelowmarsh -0.423375 0.595685 -0.711
treatment+3:fzonepioneer 0.270593 0.604163 0.448
treatmentambient:fzonepioneer -0.492087 0.586297 -0.839
week:treatment+3:fzonelowmarsh 0.007062 0.026282 0.269
week:treatmentambient:fzonelowmarsh 0.075966 0.024696 3.076
week:treatment+3:fzonepioneer 0.016768 0.023624 0.710
week:treatmentambient:fzonepioneer 0.055656 0.022369 2.488
Pr(>|z|)
(Intercept) 2.68e-06 ***
week 0.000699 ***
treatment+3 0.789579
treatmentambient 0.381149
fzonelowmarsh 3.66e-05 ***
fzonepioneer < 2e-16 ***
week:treatment+3 0.905880
week:treatmentambient 0.081716 .
week:fzonelowmarsh 0.004194 **
week:fzonepioneer 0.069808 .
treatment+3:fzonelowmarsh 0.559208
treatmentambient:fzonelowmarsh 0.477248
treatment+3:fzonepioneer 0.654239
treatmentambient:fzonepioneer 0.401293
week:treatment+3:fzonelowmarsh 0.788157
week:treatmentambient:fzonelowmarsh 0.002098 **
week:treatment+3:fzonepioneer 0.477846
week:treatmentambient:fzonepioneer 0.012844 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation matrix not shown by default, as p = 18 > 12.
Use print(x, correlation=TRUE) or
vcov(x) if you need it
optimizer (Nelder_Mead) convergence code: 0 (OK)
Model failed to converge with max|grad| = 0.00689502 (tol = 0.002, component 1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?
> summary(glmm.1)
Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) [glmerMod]
Family: poisson ( log )
Formula: total_no ~ week * treatment + fzone + (1 | plot)
Data: subset
Control:
glmerControl(optimizer = c("bobyqa", "Nelder_Mead"), optCtrl = list(maxfun = 1e+05))
AIC BIC logLik deviance df.resid
3323.6 3359.6 -1652.8 3305.6 396
Scaled residuals:
Min 1Q Median 3Q Max
-7.2154 -1.0578 -0.0778 0.9660 12.3568
Random effects:
Groups Name Variance Std.Dev.
plot (Intercept) 0.25 0.5
Number of obs: 405, groups: plot, 27
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.704335 0.225066 7.573 3.66e-14 ***
week -0.082407 0.002762 -29.831 < 2e-16 ***
treatment+3 -0.006115 0.235784 -0.026 0.97931
treatmentambient 0.006505 0.234298 0.028 0.97785
fzonelowmarsh 1.591394 0.243523 6.535 6.37e-11 ***
fzonepioneer 3.493139 0.242456 14.407 < 2e-16 ***
week:treatment+3 0.012080 0.003708 3.258 0.00112 **
week:treatmentambient 0.017372 0.003845 4.519 6.23e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) week trtm+3 trtmnt fznlwm fznpnr wk:t+3
week -0.107
treatment+3 -0.550 0.102
tretmntmbnt -0.563 0.103 0.605
fzonelwmrsh -0.562 0.000 -0.010 0.004
fzonepioner -0.565 0.000 -0.009 0.005 0.523
wk:trtmnt+3 0.080 -0.745 -0.141 -0.076 0.000 0.000
wk:trtmntmb 0.077 -0.719 -0.079 -0.141 0.000 0.000 0.535
optimizer (Nelder_Mead) convergence code: 0 (OK)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
and without optimizers
Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) [glmerMod]
Family: poisson ( log )
Formula: total_no ~ week * treatment * fzone + (1 | plot)
Data: subset
AIC BIC logLik deviance df.resid
3312.7 3388.7 -1637.3 3274.7 386
Scaled residuals:
Min 1Q Median 3Q Max
-6.9475 -1.0915 -0.0573 0.9091 12.2790
Random effects:
Groups Name Variance Std.Dev.
plot (Intercept) 0.2371 0.4869
Number of obs: 405, groups: plot, 27
Fixed effects:
Estimate Std. Error z value
(Intercept) 1.553798 0.331032 4.694
week -0.052487 0.015483 -3.390
treatment+3 -0.120870 0.452937 -0.267
treatmentambient 0.375292 0.428522 0.876
fzonelowmarsh 1.829767 0.443244 4.128
fzonepioneer 3.614629 0.435442 8.301
week:treatment+3 -0.002754 0.023291 -0.118
week:treatmentambient -0.038247 0.021971 -1.741
week:fzonelowmarsh -0.051666 0.018045 -2.863
week:fzonepioneer -0.028577 0.015761 -1.813
treatment+3:fzonelowmarsh 0.358579 0.613986 0.584
treatmentambient:fzonelowmarsh -0.423375 0.595685 -0.711
treatment+3:fzonepioneer 0.270593 0.604163 0.448
treatmentambient:fzonepioneer -0.492087 0.586297 -0.839
week:treatment+3:fzonelowmarsh 0.007062 0.026282 0.269
week:treatmentambient:fzonelowmarsh 0.075966 0.024696 3.076
week:treatment+3:fzonepioneer 0.016768 0.023624 0.710
week:treatmentambient:fzonepioneer 0.055656 0.022369 2.488
Pr(>|z|)
(Intercept) 2.68e-06 ***
week 0.000699 ***
treatment+3 0.789579
treatmentambient 0.381149
fzonelowmarsh 3.66e-05 ***
fzonepioneer < 2e-16 ***
week:treatment+3 0.905880
week:treatmentambient 0.081716 .
week:fzonelowmarsh 0.004194 **
week:fzonepioneer 0.069808 .
treatment+3:fzonelowmarsh 0.559208
treatmentambient:fzonelowmarsh 0.477248
treatment+3:fzonepioneer 0.654239
treatmentambient:fzonepioneer 0.401293
week:treatment+3:fzonelowmarsh 0.788157
week:treatmentambient:fzonelowmarsh 0.002098 **
week:treatment+3:fzonepioneer 0.477846
week:treatmentambient:fzonepioneer 0.012844 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation matrix not shown by default, as p = 18 > 12.
Use print(x, correlation=TRUE) or
vcov(x) if you need it
optimizer (Nelder_Mead) convergence code: 0 (OK)
Model failed to converge with max|grad| = 0.00689502 (tol = 0.002, component 1)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?
summary(glmm.1)
Generalized linear mixed model fit by maximum likelihood (Laplace
Approximation) [glmerMod]
Family: poisson ( log )
Formula: total_no ~ week * treatment + fzone + (1 | plot)
Data: subset
AIC BIC logLik deviance df.resid
3323.6 3359.6 -1652.8 3305.6 396
Scaled residuals:
Min 1Q Median 3Q Max
-7.2154 -1.0578 -0.0778 0.9660 12.3568
Random effects:
Groups Name Variance Std.Dev.
plot (Intercept) 0.25 0.5
Number of obs: 405, groups: plot, 27
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.704335 0.225066 7.573 3.66e-14 ***
week -0.082407 0.002762 -29.831 < 2e-16 ***
treatment+3 -0.006115 0.235784 -0.026 0.97931
treatmentambient 0.006505 0.234298 0.028 0.97785
fzonelowmarsh 1.591394 0.243523 6.535 6.37e-11 ***
fzonepioneer 3.493139 0.242456 14.407 < 2e-16 ***
week:treatment+3 0.012080 0.003708 3.258 0.00112 **
week:treatmentambient 0.017372 0.003845 4.519 6.23e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) week trtm+3 trtmnt fznlwm fznpnr wk:t+3
week -0.107
treatment+3 -0.550 0.102
tretmntmbnt -0.563 0.103 0.605
fzonelwmrsh -0.562 0.000 -0.010 0.004
fzonepioner -0.565 0.000 -0.009 0.005 0.523
wk:trtmnt+3 0.080 -0.745 -0.141 -0.076 0.000 0.000
wk:trtmntmb 0.077 -0.719 -0.079 -0.141 0.000 0.000 0.535
optimizer (Nelder_Mead) convergence code: 0 (OK)
Model is nearly unidentifiable: very large eigenvalue
- Rescale variables?
For the minimal adequate model (the glmm.1 with optimizers)there is still the warning message with the very large eigenvalue. Here is what I did not solve by checking for similar questions:
How do I know, if this warning is telling me of a misfitted model or if I can safely ignore this? I think this warning has to do with the random effect, but I don´t know how exactly.
Is there a solution to this, which does not include scaling? I tried to rescale the only continuous variable (week) with no different result. I did not scale my response variable yet, but I don´t know if this would make a difference. I also thought about explicitly tell R to handle all factors as such, so this is also not the issue (I read this in another answer).
if this was the model I can use for my data, how would I do a post hoc analysis? I researched that for a GLMM there are the options of the emmeans() and multcomp() packages.
Would you agree with that or is a post hoc analysis unnessecary in this case?
If I did not provide you with all the information you need, please tell me and I will edit. Thank you in advance, any help is appreciated!!
(week - 7)
in place of week, it will considerably improve the conditioning of this model, and maybe you won't get those warning messages. $\endgroup$