I work in biology and I´ve done an experiment exposing an invertebrate to a pesticide at different temperatures. One of my endpoints is hatching success of their eggs. The animals lay clutches of eggs, usually 10-30 eggs. My impression is that I shouldn’t model the data using proportions as datapoints (e.g., 0.7 proportion of the eggs in one clutch hatched), but rather use raw data (1/0 for hatched/not hatched, per egg). Then I need to add “clutch-ID” as a random factor. I, therefore, plan to use a generalized linear mixed model (glmer()
from the lme4 package) with binomial family link = "logit"
.
My model:
glmer(hatchingsuccess ~ Temperature + Pesticide + (1 | clutch.id),
data = eggdata, family = binomial(link = "logit"))
The sample size is approx. 8000 eggs (in about 500 clutches). I also first included an interaction term with Temperature * Pesticide
, but then nothing was significant, so I eliminated that.
Summary:
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) ['glmerMod']
Family: binomial ( logit )
Formula: hatchingsuccess ~ Temperature + Pesticide + (1 | clutch.id)
Data: eggdata
AIC BIC logLik deviance df.resid
6879.3 6914.3 -3434.6 6869.3 8139
Scaled residuals:
Min 1Q Median 3Q Max
-5.2772 -0.2007 0.2111 0.4408 3.7051
Random effects:
Groups Name Variance Std.Dev.
Batch.id (Intercept) 5.121 2.263
Number of obs: 8144, groups: Batch.id, 560
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 0.62213 0.43920 1.416 0.15663
Temperature 0.08385 0.02709 3.096 0.00196 **
lowPesticide -0.29740 0.25770 -1.154 0.24847
highPesticide -0.50853 0.26549 -1.915 0.05543 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
optimizer (Nelder_Mead) convergence code: 0 (OK)
Model failed to converge with max|grad| = 0.0023972 (tol = 0.002, component 1)
The proportions of eggs hatched look like this (the different colours represent pesticide treatments, and the three plots are for three different temperatures.
These are diagnostic plots using the package DHARMa:
Does this R output from the model and diagnostics look ok? I got an answer about the converge problem and will look into that.
Is it ok to present these proportion plots and refer to model statistics, or do I need to plot single datapoints on the y-axis and a line for the model? I think these proportion plots more clearly show the data/results, but I need to have some stats to refer to.
glmer
. Also, you can fit a binomial model in a situation like this, without having to use a random effect, by specifying the outcome for each clutch as "a two-column integer matrix: the first column gives the number of successes and the second the number of failures" (Help page forfamily
in R). Maybe try that. $\endgroup$glmer()
to deal with difficult fits. You should learn about that if you are going to do a lot of mixed-modeling. I suspect that the 2-column approach will avoid the problem completely in this case. $\endgroup$