Generalized mixed models lmer with proportion data
Generalized mixed models using lmer are introduced on p. 546. The data concern the proportion of insects killed by pesticide application in four pseudoreplicated plots within each randomly selected half-field in six different farms (blocks A to F):
data<-read.table("c:\\temp\\insects.txt",header=T) attach(data) names(data) [1] "block" "treatment" "replicate" "dead" "alive"
The response variable for the binomial analysis is created like this:
y<-cbind(dead,alive)
We intend to use the lmer function, which is part of the lme4 library:
library(lme4)
The model is fitted by specifying the fixed effects (block and treatment), the random effects (replicates within treatments within blocks), the error family (binomial) and the dataframe name (data) like this:
model<-lmer(y~block+treatment+(1|block/treatment),binomial,data=data) summary(model)
This summary indicates a very high level of overdispersion (estimated scale (compare to 1) = 2.19) so we refit the model with quasi-binomial rather than binomial errors:
model<-lmer(y~block+treatment+(1|block/treatment),quasibinomial,data=data) summary(model) Generalized linear mixed model fit using Laplace Formula: y ~ block + treatment + (1 | block/treatment) Data: data Family: quasibinomial(logit link) AIC BIC logLik deviance 255.2 272 -118.6 237.2 Random effects: Groups Name Variance Std.Dev. treatment:block (Intercept) 2.4134e-09 4.9127e-05 block (Intercept) 2.4134e-09 4.9127e-05 Residual ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access