how to model random effects AND overdispersion in GLM
Posted: Sat Jan 18, 2020 7:34 pm
Dear Jamovi mavens,
I'm a new user and delighted that Jamovi exists. I loaded the gamlj module because I need to analyze overdispersed count data while also modeling random effects associated with a cluster variable ("ID" in my R example below), where "a" and "b" are two levels of a factor "name" and "counts" are the counts.
Among the tools I can see Poisson overdispersion can be modeled in the Generalized Linear Models interface, and random effects on a cluster variable can be modeled in Generalized Mixed Models, but I cannot see how to put them both in the same model.
If it helps, my R code for a simple model using the lme4 package looks something like below but I have others with multiple factors with multiple levels - love the jamovi interface for that.
Thanks,
onyaw
a<-1*(data$name=='A')
b<-1*(data$name=='B')
counts_d<-data$counts
rep_ind<-c(1:length(a))
ID_e<-(data$ID)
#FIT FULL MODEL WITH INTERACTION TERMS
fit_a<-glmer(counts_d~(1|rep_ind) +(1|ID_e) + b, family='poisson')
#FIT NULL MODEL
fit_a0<-glmer(counts_d~(1|rep_ind) +(1|ID_e), family='poisson')
lr_a<- as.numeric(-2*(logLik(fit_a0)-logLik(fit_a)))
p_a<-exp(pchisq(lr_a,1,lower.tail=F,log.p=T)) #P-VALUE FOR INTERACTION TEST
p_a
I'm a new user and delighted that Jamovi exists. I loaded the gamlj module because I need to analyze overdispersed count data while also modeling random effects associated with a cluster variable ("ID" in my R example below), where "a" and "b" are two levels of a factor "name" and "counts" are the counts.
Among the tools I can see Poisson overdispersion can be modeled in the Generalized Linear Models interface, and random effects on a cluster variable can be modeled in Generalized Mixed Models, but I cannot see how to put them both in the same model.
If it helps, my R code for a simple model using the lme4 package looks something like below but I have others with multiple factors with multiple levels - love the jamovi interface for that.
Thanks,
onyaw
a<-1*(data$name=='A')
b<-1*(data$name=='B')
counts_d<-data$counts
rep_ind<-c(1:length(a))
ID_e<-(data$ID)
#FIT FULL MODEL WITH INTERACTION TERMS
fit_a<-glmer(counts_d~(1|rep_ind) +(1|ID_e) + b, family='poisson')
#FIT NULL MODEL
fit_a0<-glmer(counts_d~(1|rep_ind) +(1|ID_e), family='poisson')
lr_a<- as.numeric(-2*(logLik(fit_a0)-logLik(fit_a)))
p_a<-exp(pchisq(lr_a,1,lower.tail=F,log.p=T)) #P-VALUE FOR INTERACTION TEST
p_a