There's a way to do Poisson or logit mixed effects and Poisson or logit GEE in R. What's the difference between GEE and the mixed effects models for Poisson / logistic regression? I heard its the difference between estimating the population level numbers and the individual numbers (public health versus individual patient treatment), that is:

  • GEE is like what if we gave everyone the treatment in the population including the non-sick, and
  • mixed effects is like what if we gave individuals (sick and non-sick) the treatment.

Is that right?

(I'm sure lme4, geeglm, glmm has a way to do these.)

I heard GEE is a robust estimator that guards against covariance pattern misspecification, but mixed effects is better for missing data. Can someone explain that?


When you have a random intercept, it's like have an exchangeable correlation structure, and when you have random intercepts and slopes, it's like having an AR-1 correlation structure... assuming the random effects are simple rather than cross-nested. These covariance matrices actually cover a few cases that random effects do not. Syntactically they're often specified in a very similar way, which can be misleading.

You will recall that for linear models with identity link, the interpretation of effects for GEE and mixed models is that GEE estimates "population averaged" effects and mixed models estimates "individual level" effects. This convention borrows over to non-identity links such as binomial and Poisson models. The GEE estimates marginal effects, interpreted as "population averaged" whereas the mixed model estimates "individual effects". Dovetail this with the proper interpretation of effect for logit and poisson models, and the only remaining challenge is actually specifying and fitting these models.

As an example, suppose I was interested in the rate of asthma exacerbations before and after enacting a public policy to reduce air pollution. Suppose this policy is just unbelievably effective: I close all industry and force people to buy electric cars. An inadvertent effect is that severe asthmatics actually move to my city seeking better quality of life. Now I have data on hospitalizations for asthma attacks over time. In my GEE model I say asthma hospitalizations go UP after enacting this policy. In my mixed model, I say asthma hospitalizations go DOWN after enacting this policy. They are both right, it's just that I did not have quite as many severe asthmatics living in my city before cleaning the air. The mixed model is useful because I can predict that those who moved to my city had far worse asthma exacerbations before I ever observed them. The GEE is useful because I know my hospitals will actually have more patients in them seeking treatment for asthma.

Example (in R!)


n <- 5000
id.wide <- 1:n
year <- 2000:2010
post <- year > 2007
bl.sev <- sample(0:2, n, prob = c(0.5, 0.25, 0.25), replace=T) ## baseline severity
id.mig <- id.wide > n*0.65 ## the last 30% migrate in
minid.mid <- min(id.wide[id.mig])
bl.sev[id.mig]  <- 2 ## all migrants are severe

id.long <- rep(1:n, each=length(year))
year.long <- rep(year, n)

ae.int <- -4 + c(0, 1.2, 5.3)[bl.sev[id.long]+1] + ## intensity of asthma exacerbation
  -0.1 * (year.long > 2007)

# ae.int <- -4 + c(0, 1.2, 5.3)[bl.sev[id.long]+1]  ## intensity of asthma exacerbation
# ae.int <-  -1 * (year.long > 2007) + 1*(bl.sev[id.long]==2)  ## with an interaction effect (improves mild/moderate only)

ae <- rpois(length(id.long), exp(ae.int))

ae[id.long > minid.mid & year.long <= 2007] <- NA ## drop AEs from severe asthmatics during pre period

post.long <- year.long > 2007

glm(ae ~ post.long, family=poisson)
geefit <- geeglm(ae ~ post.long, id=id.long, family=poisson, corstr = "exchangeable")
mefit <- glmer(ae ~ post.long + (1|id.long), family=poisson)


The essential parts of the output are:

From the GEE

              Estimate Std.err    Wald Pr(>|W|)    
(Intercept)    0.54562 0.01561 1221.25   <2e-16 ***
post.longTRUE  0.00304 0.00670    0.21     0.65  

From the mixed effects model:

Fixed effects:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)    -1.2041     0.0441  -27.28  < 2e-16 ***
post.longTRUE  -0.0411     0.0123   -3.35  0.00082 ***

Which shows effects of the desired opposite direction. Getting "significant" results is just a matter of ramping up sample size.

  • $\begingroup$ Are you saying given the SAME dataset, GEE says hospitalizations go UP and Mixed Effects says hospitalizations go DOWN? What about the p-values? Are the p-values consistent regardless of estimation method? $\endgroup$ – user252477 Aug 12 '19 at 14:56
  • $\begingroup$ @Germania yes, it's ecological fallacy played out in real time. And yes, the p-values are significant provided you have enough data. $\endgroup$ – AdamO Aug 12 '19 at 15:03
  • 1
    $\begingroup$ In Poisson mixed effects model with only random intercepts the fixed effects coefficients for the covariates have a marginal interpretation the same as in a GEE - only the intercept has a different interpretation. $\endgroup$ – Dimitris Rizopoulos Aug 12 '19 at 15:51
  • 2
    $\begingroup$ @AdamO: Dimitris makes a valid point, which warrants revisiting your currently misleading statement that "there is no difference between GEE and mixed effects for models for binary or count data (logit / poisson).". If you leave that statement as it is right now, you risk confusing people who will read your answer, especially since the answer was accepted as the "correct answer". $\endgroup$ – Isabella Ghement Aug 12 '19 at 19:45
  • 1
    $\begingroup$ @IsabellaGhement thanks. you reveal how confusing the statement was because the point was about interpretation of effects, and a third point entirely to Dimitris earlier remark. Please see edit. $\endgroup$ – AdamO Aug 12 '19 at 19:59

A couple of points:

  • When you use the identity link function both the GEE and a (linear) mixed model give you coefficients that have a population/marginal interpretation.
  • In all other cases where you use a nonlinear link function, such as the logit or the log, there is a difference in the interpretation of the coefficients. Namely, GEEs provide coefficients with a population/marginal interpretation whereas mixed models provide coefficients with a subject-specific interpretation.
  • The population/marginal interpretation refers to groups of subjects. For example, in the case of a dichotomous outcome and the logit link the GEE will give you a coefficient for the sex variable you that is the log odds ratio between the groups of males versus females.
  • The subject-specific interpretation on the other hand is at the subject level. Continuing on the previous example, the coefficient for sex from a mixed effects logistic regression would be the log odds ratio if a specific subject changed sex.
  • It is possible to obtain coefficients with a population/marginal interpretation from mixed models. For example, in the GLMMadaptive package I’ve written, check function marginal_coefs() illustrated here.
  • Mixed models provide valid inferences under the missing at random missing data mechanism, whereas the basic version of GEEs only under the more restrictive missing completely at random mechanism.
  • The sandwich estimator in GEEs better protects against a misspecification of the working correlation structure in restrictive settings, i.e., when you have a balanced design, with few categorical covariates, and many subjects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy