[R-sig-ME] modelling proportions, with aggregated data, and the new/old lme4

Adam Smith raptorbio at hotmail.com
Wed Mar 21 17:06:40 CET 2012


Not sure what I'm missing here, but I'm not finding the offset Poisson and binomial to be equal with my dataset.  

> sessionInfo()

R version 2.14.1 (2011-12-22)

Platform: x86_64-pc-mingw32/x64 (64-bit)



locale:

[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United 
States.1252    LC_MONETARY=English_United States.1252 
LC_NUMERIC=C                          

[5] LC_TIME=English_United States.1252    



attached base packages:

 [1] stats4    splines   tcltk     stats     graphics  grDevices utils     datasets  methods   base     



other attached packages:

 [1] lme4_0.999375-42   bbmle_1.0.4.1      numDeriv_2010.11-1 
R2admb_0.7.5       Hmisc_3.9-1        survival_2.36-10   
NCStats_0.2-7      sciplot_1.0-9     

 [9] mgcv_1.7-13        Matrix_1.0-3       lattice_0.20-0     
MASS_7.3-16        AED_1.0            circular_0.4-3     
boot_1.3-4         plotrix_3.3-3     



loaded via a namespace (and not attached):

 [1] car_2.0-12        cluster_1.14.1    gamm4_0.1-5       
gdata_2.8.2       glmmADMB_0.7.2.5  gplots_2.10.1     grid_2.14.1       
gtools_2.6.2      multcomp_1.2-9   

[10] nlme_3.1-103      TeachingDemos_2.7 tools_2.14.1     

> #
> # Compare offset Poisson with binomial
> invlogit<-function(x) exp(x)/(1+exp(x))
> test <- read.csv("http://dl.dropbox.com/u/23278690/test.csv", header=T)
> b.glm <- glm(cbind(success,total) ~ (a+b+c)^2 - 1, family="binomial", data=test)
> p.glm <- glm(success ~ (a+b+c)^2 - 1 + offset(log(total)), family="poisson", data=test)
> #
> exp(coef(p.glm))
         a          b          c        a:b        a:c        b:c 
0.03225038 0.15195288 1.40174126 3.48192066 1.01892662 0.97212475 
> #
> inv.logit(coef(b.glm))
         a          b          c        a:b        a:c        b:c 
0.03158208 0.13227007 0.58381656 0.77643718 0.50446378 0.49263445 
> #
> all.equal(exp(coef(p.glm)), invlogit(coef(b.glm)))
[1] "Mean relative difference: 0.6428341"

Could it be related to the number of zeros?

Adam Smith
Dept. Natural Resources Science
University of Rhode Island


 		 	   		  



More information about the R-sig-mixed-models mailing list