Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: GLMM glmer vs glmmPQL

Tags:

r

glm

lme4

What is the syntax in glmmPQL for multiple random effects?

With glmer my code looks like:

fit<- glmer(A~B+C+ (1 | D)+ (1 | E), family = gaussian, data=data)

how to rewrite the same exact thing using glmmPQL?

I was trying:

fit<- glmmPQL(A~B+C, random=c (~1 | D, ~1 | E), family = gaussian, data=data)

but it gives an error.

And what is the major difference between glmer and glmmPQL?

like image 698
Liza Avatar asked Oct 28 '25 14:10

Liza


2 Answers

Based on the example you provided, the model with glmmPQL would be specified as:

fit <- glmmPQL(A ~ B + C, random = list(D = ~1, E = ~1), family = gaussian, data = data)

AFAIK, the major difference between glmer (which is provided by the package lme4) and glmmPQL (which relies on function lme, from the nlme pacakge) is that the parameter estimation algorithm used in nlme is not optimized for dealing with crossed random effects, which are associated with a sparse design matrix, while lme4 takes advantage of this structure; see, e.g., Pinheiro & Bates, "Mixed-Effects Models in S and S-PLUS", Springer, 2000, pp. 163. Further references on the differences between lmer/glmer and lme are the usual:

https://stats.stackexchange.com/questions/64226/lme-and-lmer-comparison https://stat.ethz.ch/pipermail/r-help/2006-October/115572.html

like image 118
tguzella Avatar answered Oct 30 '25 05:10

tguzella


And what is the major difference between glmer and glmmPQL?

To add to tguzella answer then glmmPQL uses PQL which has some known bias issues whilst glmer uses a Laplace approximation or Gauss-Hermite quadrature which are better approximations. See the comments here by Ben Bolker and the papers cited therein. This may be a major downside for glmmPQL depending on the model you estimate and the data you have (e.g. it is not bad for large cluster in some cases).

The glmer function can however not fit certain types of correlation structures. See e.g., the links in the aforementioned answer or the comments on this page.

like image 23
Benjamin Christoffersen Avatar answered Oct 30 '25 05:10

Benjamin Christoffersen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!