daijiang / phyr

Functions for phylogenetic analyses
https://daijiang.github.io/phyr/
GNU General Public License v3.0
30 stars 10 forks source link

different estimates from glmer and pglmm #71

Open heliconius-maps opened 2 years ago

heliconius-maps commented 2 years ago

Hi, I've noticed that I get different output from glmer and pglmm, when I think(?) the output should be more similar (example below). I imagine that I am specifying the models differently in some way, but it's not clear to me how. Could you possibly provide some guidance? Thank you, Neil

library(phyr) library(lme4)

some example data

s <- c(11, 12, 0, 1, 4, 4, 2, 3, 24, 14, 5, 6, 7, 15, 14, 9, 0, 0, 2, 11) # successes f <- c(2, 2, 2, 2, 4, 6, 5, 3, 1, 1, 6, 3, 11, 3, 1, 0, 1, 5, 2, 3) # failures ID<-c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U")

dat.long<-data.frame(s,f,ID)

glmer

m1<-glmer(cbind(s,f) ~ 1 + (1|ID),data=dat.long,family="binomial")

PGLMM

m2<-pglmm(cbind(s,f) ~ 1 + (1|ID), data=dat.long,family="binomial", add.obs.re = FALSE,REML = FALSE) summary(m1) summary(m2) logLik(m1) m2$logLik

daijiang commented 2 years ago

Hi, This is because lme4 and phyr used different approaches for glmm.