[R-sig-ME] Fixing singularity in a generalized linear mixed effect model
René
b|mono@om @end|ng |rom gm@||@com
Tue Mar 26 10:08:25 CET 2019
Hi Allessandra,
your model output says:
"Number of obs: 292"
and your model has 2 fixed effects and 5 (!) random effects.
- If - all these random effects are fully crossed. Then assuming you have
19 participants (e.g. 1|observers), and 4 random effects crossed on them
with two levels each (2*2*2*2 = 16 cells), would make about 292
observations.
Now you see this math uncovers the most likely problem: A random effect
(intercept) factor is urgently recommended to have least! 6 levels to make
such a model meaningful).
If all these random effects are not fully crossed, then the model is
misspecified, i.e. defining random intercepts for factor 1 separately from
random intercepts for another factor 2, when factor 1 is nested in factor
2, is over-identifying the randomness in your model -> singular.
So,
only define random intercepts for factors with more then 6 levels (move
those factors with less levels to the fixed effects instead to control for
them)
only define separate random intercepts for factors that are crossed; for
instance the factors boat name and lance seem suspicious. I guess, there is
a world in which a 'lance 1' can only be on boat 'atlantis' to be used for
fishing, but not on boat 'moby dick'. In this case, having a random
intercept for "boat name" in addition to 'lance' would not add anything to
the model, since lances would already cover the variance of boats (lances
nested in boats).
Get more observations
Rerun the model
Should be fine :)
If singularities still occur use Bayesian models or come back here :))
Best, René
Am Di., 26. März 2019 um 09:30 Uhr schrieb Thierry Onkelinx via
R-sig-mixed-models <r-sig-mixed-models using r-project.org>:
> Dear Alessandra,
>
> Your problem is hard to diagnose without the data. Can you make the data
> available? Does the combination of factors lead to unique observations? Or
> do some combinations have only zero's?
>
> Best regards,
>
> ir. Thierry Onkelinx
> Statisticus / Statistician
>
> Vlaamse Overheid / Government of Flanders
> INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
> FOREST
> Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> thierry.onkelinx using inbo.be
> Havenlaan 88 bus 73, 1000 Brussel
> www.inbo.be
>
>
> ///////////////////////////////////////////////////////////////////////////////////////////
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to say
> what the experiment died of. ~ Sir Ronald Aylmer Fisher
> The plural of anecdote is not data. ~ Roger Brinner
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of data.
> ~ John Tukey
>
> ///////////////////////////////////////////////////////////////////////////////////////////
>
> <https://www.inbo.be>
>
>
> Op wo 20 mrt. 2019 om 23:19 schreef Alessandra Bielli <
> bielli.alessandra using gmail.com>:
>
> > Dear List
> >
> > I am fitting this model using the lme4 package, in order to obtain catch
> > estimates using the predict function
> >
> > m1 <- glmer(Count ~ CE + offset(log(Effort)) + (1|SetYear) +(1|Season) +
> > (1|Lance.N) + (1|Boat.Name) + (1|Observer.Name), data =
> > Data, glmerControl(optimizer = "bobyqa"), family=
> > "poisson")
> >
> >
> > where: CE is a categorical (control or treatment), Effort is numerical
> > (fishing effort), and all the other variables are random effects.
> >
> > *My problem is that I get a warning message saying that the model is
> > singular*
> >
> > *>summary(m1)*
> >
> > Generalized linear mixed model fit by maximum likelihood (Laplace
> > Approximation) [glmerMod]
> > Family: poisson ( log )
> > Formula: Count ~ CE + offset(log(Effort)) + (1 | SetYear) + (1 |
> > Season) + (1 | Lance.N) + (1 | Boat.Name) + (1 | Observer.Name)
> > Data: Data
> > Control: glmerControl(optimizer = "bobyqa")
> >
> > AIC BIC logLik deviance df.resid
> > 148.6 174.3 -67.3 134.6 285
> >
> > Scaled residuals:
> > Min 1Q Median 3Q Max
> > -0.4852 -0.1758 -0.1339 -0.1227 3.5980
> >
> > Random effects:
> > Groups Name Variance Std.Dev.
> > Lance.N (Intercept) 2.259e+00 1.503e+00
> > Boat.Name (Intercept) 0.000e+00 0.000e+00
> > Observer.Name (Intercept) 0.000e+00 0.000e+00
> > Season (Intercept) 4.149e-17 6.442e-09
> > SetYear (Intercept) 0.000e+00 0.000e+00
> > Number of obs: 292, groups:
> > Lance.N, 146; Boat.Name, 21; Observer.Name, 5; Season, 4; SetYear, 4
> >
> > Fixed effects:
> > Estimate Std. Error z value Pr(>|z|)
> > (Intercept) -2.5751 0.6612 -3.895 9.83e-05 ***
> > CEE -0.5878 0.5003 -1.175 0.24
> > ---
> > Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> >
> > Correlation of Fixed Effects:
> > (Intr)
> > CEE -0.257
> > *convergence code: 0*
> > *singular fit*
> >
> > I am aware that there are a lot of random effects and some of them have a
> > number of levels <5. However, this study was carried out under real
> fishery
> > conditions, so these random effects seemed all important to me.
> >
> > I removed the random effects with variance zero as suggested here
> >
> >
> https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#singular-models-random-effect-variances-estimated-as-zero-or-correlations-estimated-as---1
> > until I removed them all and found myself with a glm instead.
> >
> > My questions are
> >
> > - why the variance of Lance.N, initially positive, becomes zero after I
> > remove the other random effects that had variance equal zero?
> > - is it acceptable to fit a glm just because all the random effect
> > variances were zero?
> >
> > I hope I gave all the information you need.
> >
> > Thanks for any advice!
> >
> > Alessandra
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-mixed-models using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> >
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list