[R] glm(family=binomial) and lmer

Chris O'Brien obrienc at email.arizona.edu
Tue Aug 14 17:47:41 CEST 2007

Dear R users,

I've notice that there are two ways to conduct a binomial GLM with binomial 
counts using R.  The first way is outlined by Michael Crawley in his 
"Statistical Computing book" (p 520-521):

 >dead = c(2,10,40,96,98)
 >response = cbind(dead,batch-dead)

Which returns (in part):
             Estimate Std. Error z value Pr(>|z|)
(Intercept)  -4.5318     0.4381  -10.35   <2e-16 ***
log(dose)     1.9644     0.1750   11.22   <2e-16 ***
Null deviance: 408.353  on 4  degrees of freedom
Residual deviance:  10.828  on 3  degrees of freedom
AIC: 32.287

Another way to do the same analysis is to reformulate the data, and use GLM 
with weights:

 >number = c(batch-dead,dead)
 >data1=as.data.frame(cbind (y1,dose,number))

Which returns:

             Estimate Std. Error z value Pr(>|z|)
(Intercept)  -4.5318     0.4381  -10.35   <2e-16 ***
log(dose1)    1.9644     0.1750   11.22   <2e-16 ***
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 676.48  on 9  degrees of freedom
Residual deviance: 278.95  on 8  degrees of freedom
AIC: 282.95

Number of Fisher Scoring iterations: 6

These two methods are similar in the parameter estimates and standard 
errors, however the deviances, their d.f., and AIC differ.  I take the 
first method to be the correct one.
However, I'm really interested in conducting a GLM binomial mixed model, 
and I am unable to figure out how to use the first method with the lmer 
function from the lme4 library, e.g.

 >model3=lmer(y~log(dose)+time|ID)    # the above example data doesn't have 
the random effect, but my own data set does.

   Does anyone have any suggestions?


Chris O'Brien

More information about the R-help mailing list