Guides  /  GEE

Generalised estimating equations

GEE extends ordinary regression to data where observations are not independent, and reports the average effect across a population rather than the effect within one person or one ward. This guide covers what it estimates, how to choose a working correlation structure, why the robust standard errors matter more than the structure you pick, how many clusters you need, and when a mixed effects model is the better answer.

Sidra Khan Written and reviewed by Sidra Khan, Lead Biostatistician
Updated 26 October 202614 min read
What are generalised estimating equations?

GEE is a method for fitting regression models when observations are correlated rather than independent, as they are whenever measurements repeat within a person or group. Instead of modelling where that correlation comes from, GEE treats it as a nuisance, makes a rough assumption about it, and then corrects the standard errors so that the assumption does not have to be right. What it gives you is the population-averaged effect: how the outcome shifts across the population as a whole, not within any one individual.

Definition

What GEE does

Ordinary regression assumes every observation carries independent information. That assumption fails the moment the same person is measured twice, or two patients share a ward. When it fails, the coefficients are usually still reasonable but the uncertainty around them is wrong, and wrong in the direction of making findings look stronger than they are. The scale of the error is set by how much the observations repeat each other, which is covered in detail in the guide to clustered data and the unit of analysis.

Generalised estimating equations, introduced by Liang and Zeger in 1986, extend the generalised linear model to this situation. You still choose a link function and an outcome distribution as you would for logistic regression or Poisson regression. GEE adds a statement about how observations within a cluster are correlated, uses it to weight the data more sensibly, and then computes standard errors in a way that protects you if that statement was wrong.

The useful trick at the centre of GEE

You are allowed to be wrong about the correlation. Provided the model for the mean is right and you use robust standard errors, GEE still gives consistent estimates and valid inference even if the correlation structure you specified is badly misspecified. Getting the structure closer to the truth buys efficiency, not validity.

The key distinction

Population-averaged, not individual

This is the part most often got wrong in write-ups, and it is not a technicality. GEE answers a question about populations. A mixed effects model answers a question about individuals.

Suppose a service change is associated with better outcomes. The GEE coefficient says what happens to the average outcome across the whole population of wards if every ward adopts the change. The mixed model coefficient says what happens within a given ward when that ward adopts it. Both are legitimate. They are different numbers answering different questions, and a paper that reports one while describing the other has misstated its own finding.

For continuous outcomes with an identity link the two coincide, which is why the distinction is easy to forget. For binary outcomes they do not. The marginal odds ratio from GEE is pulled towards 1 compared with the conditional odds ratio from a mixed model, and the gap widens as variation between clusters increases. Neither is wrong. They are measuring different things.

Question you are askingMethodWhat the coefficient means
If this changed everywhere, what happens to the population average?GEEPopulation-averaged, or marginal, effect
If this changed for this ward, what happens to this ward?Mixed effects modelCluster-specific, or conditional, effect
How much do wards differ from each other?Mixed effects modelGEE cannot answer this at all

Specification

The three choices you have to make

Fitting a GEE means stating three things. Every one of them belongs in your methods section.

✓The link function and distribution. Identity and Gaussian for continuous outcomes, logit and binomial for binary, log and Poisson for counts. Exactly the choice you would make for an ordinary generalised linear model.
✓The working correlation structure. Your rough description of how observations within a cluster relate to each other.
✓The standard error type. Robust, almost always. This is the choice that decides whether the analysis is defensible.

A fourth decision arrives if you are selecting between models. The usual likelihood-based criteria do not apply, because GEE is not a likelihood method. QIC, proposed by Pan in 2001, is the quasi-likelihood analogue of AIC and is what model selection should be based on.

The structure

Working correlation structures

The working correlation describes how observations within a cluster hang together. Choose it to match the design rather than by trying several and keeping the one that gives the best p-value.

StructureAssumptionUse it when
IndependenceNo correlation at allYou want the robust standard errors to do all the work. Valid, and less efficient than it could be.
ExchangeableEvery pair within a cluster is equally correlatedOrder does not matter. Patients within a practice, pupils within a school. The usual default.
AR(1)Correlation decays as observations get further apart in timeMeasurements at regular intervals where nearby ones are more alike.
UnstructuredEvery pair has its own correlation, estimated freelyFew time points and many clusters. It consumes parameters quickly and often fails to converge.
Exchangeable is the sensible default for most applied work

Unless your observations have a natural order in time, exchangeable describes the design and costs almost nothing. Reserve unstructured for a handful of fixed time points with plenty of clusters, and be ready for convergence problems.

The important bit

Why robust standard errors carry the method

The robust or sandwich estimator, also called the Huber-White or empirical variance estimator, computes uncertainty from how much the clusters actually vary rather than from the correlation structure you assumed. That is what lets you be wrong about the structure without being wrong about the answer.

The practical consequence is that your confidence intervals come from the observed between-cluster variation. If you fit a GEE with model-based standard errors instead, you have thrown away the protection and are relying on the working correlation being correct, which it almost never is. Software defaults vary, so check which one you have actually used rather than assuming.

There is one condition. The sandwich estimator is a large-sample result, and "large" here means the number of clusters, not the number of rows. Fifty thousand observations from twelve clinics is a small sample for this purpose.

Worked example one

What the robust standard errors actually buy you

Forty clinics, fifteen patients each, so 600 observations. The exposure is applied at clinic level and the intraclass correlation is 0.30. Here is what happens to the standard error depending on whether the clustering is respected.

Step 1. The naive analysis

Treat all 600 observations as independent and compare the two groups.

standard error = 0.082

Step 2. The analysis that respects the design

Account for the fact that the 600 observations came from only 40 independently allocated units.

standard error = 0.188

Step 3. Compare, and check against theory

0.188 / 0.082 = 2.29

The honest standard error is 2.29 times larger. Now check that against the design effect:

design effect = 1 + (m − 1) × ICC = 1 + 14 × 0.30 = 5.20
√5.20 = 2.28

The two agree, as they must. Standard errors inflate by the square root of the design effect, and that is precisely the correction the robust estimator applies.

Step 4. What that does to a p-value

A t statistic is the estimate divided by its standard error, so dividing the standard error by 2.29 multiplies the t statistic by 2.29. An effect that would sit at t = 1.3 and be reported as non-significant becomes t = 2.98 under the naive analysis, with a p-value around 0.003. The naive model does not produce a slightly optimistic answer. It produces a confident one that is wrong.

Check which standard errors you actually got

Fitting a GEE with model-based rather than robust standard errors throws away the protection entirely and leaves you relying on the working correlation being correct. Software defaults differ, so verify rather than assume. If your standard errors look similar to an ordinary regression on the same data, you probably have the wrong ones.

Worked example two

How far apart marginal and conditional really are

Take a true subject-specific model with a log-odds ratio of 0.80, so a conditional odds ratio of 2.23, and vary how much clusters differ from each other. Averaging the probabilities across the population gives the marginal effect a GEE would estimate.

Between-cluster SDVarianceConditional OR
(mixed model)
Marginal OR
(GEE)
Attenuation
0.00.002.232.231.00
0.50.252.232.140.95
1.01.002.231.950.83
1.52.252.231.770.71
2.04.002.231.630.61

Reading the table

With no variation between clusters the two coincide exactly. As clusters become more different, the marginal odds ratio is pulled towards 1 while the conditional one stays where it is. At a between-cluster variance of 1.0, a conditional odds ratio of 2.23 corresponds to a marginal one of 1.95, which is an attenuation of about 17% on the log scale.

Why neither is wrong

The conditional estimate answers: if this clinic adopted the intervention, what happens in this clinic. The marginal estimate answers: if every clinic adopted it, what happens to the population average. Those are different quantities and both are useful, which is why a paper must say which one it is reporting.

The error this creates in practice

Two papers on the same question, one using GEE and one using a mixed model, will report different odds ratios and the difference can look like disagreement. It usually is not. Before concluding that studies conflict, check whether one estimated a marginal effect and the other a conditional one.

Note that this divergence only arises for non-linear links. With an identity link on a continuous outcome the two coincide regardless of how much clusters differ, which is why the distinction is easy to forget until a binary outcome appears.

Sample size

How many clusters you need

Around forty clusters is the figure usually quoted as the point below which the robust estimator becomes unreliable, and below it the standard errors are biased downwards, which defeats the entire purpose of using them.

If you have fewer, you have three reasonable options. Apply a small-sample correction such as Mancl and DeRouen, Kauermann and Carroll, or Fay and Graubard, all available in standard software. Use a mixed effects model instead, which handles small cluster counts more gracefully. Or aggregate to cluster level and analyse the summaries, which is crude but almost impossible to get wrong.

Check what your data is actually worth first

Before choosing a method, find out how much independent information you have. The free calculator turns your clusters, observations each and ICC into a design effect, an effective sample size and the ceiling you cannot pass however much more you collect.

Open the effective sample size calculator

Choosing

GEE or a mixed effects model?

The honest answer is that your research question decides, not your software or your training.

Choose GEE whenChoose a mixed effects model when
You want the population-averaged effectYou want the effect within a cluster
Clustering is a nuisance to be correctedVariation between clusters is itself of interest
You have plenty of clustersYou have relatively few clusters
You would rather not commit to a distribution for the random effectsYou need predictions for a specific cluster
Your missing data is plausibly completely at randomYour missing data is at random given the observed values

A reasonable rule of thumb for applied health and social research: if the question is about what a policy would do across a system, GEE fits. If it is about what happens to a patient, a pupil or a ward, a mixed model fits.

Limitations

Missing data, and where GEE is weak

This is the most important limitation and the one least often disclosed. Standard GEE is valid when data are missing completely at random, a stronger assumption than the missing at random condition under which likelihood methods including mixed models remain valid.

In practice that assumption is often indefensible. People drop out of studies for reasons connected to their outcomes, and app users stop logging when they feel better or when they feel far worse. If dropout relates to anything you observed, standard GEE can be biased where a mixed model would not be. The repair is weighted GEE using inverse probability weights, which needs a model for why data went missing and should be stated as the extra assumption it is.

✓GEE estimates no variance components, so it cannot tell you how much clusters differ.
✓It gives no cluster-level predictions, so it cannot say anything about an individual ward or patient.
✓It needs a decent number of clusters before the robust standard errors behave.
✓It assumes missing completely at random unless weighted.

Doing it

In R, SPSS and Stata

R

geepack is the usual choice. The data must be sorted by the cluster identifier before fitting, or the correlation structure is applied to the wrong groupings.

library(geepack)
df <- df[order(df$clinic), ]
fit <- geeglm(outcome ~ treatment + age, id = clinic,
    family = binomial, corstr = "exchangeable", data = df)
summary(fit)

geeglm reports robust standard errors by default, which is what you want. Model selection uses QIC rather than AIC: MuMIn::QIC(fit). For a small number of clusters, saws or geesmv provide small-sample corrections to the sandwich estimator.

SPSS

GEE sits under Analyze, Generalized Linear Models, Generalized Estimating Equations. The subject variable defines the clusters and the within-subject variable defines the ordering for structures such as AR(1).

GENLIN outcome (REFERENCE = FIRST) BY treatment WITH age
  /MODEL treatment age DISTRIBUTION = BINOMIAL LINK = LOGIT
  /REPEATED SUBJECT = clinic CORRTYPE = EXCHANGEABLE
    COVB = ROBUST
  /PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY SOLUTION.

COVB = ROBUST is the important line. SPSS will accept MODEL instead, which gives model-based standard errors and removes the protection the method exists to provide.

Stata

xtgee is built in and needs the panel structure declared first.

xtset clinic
xtgee outcome treatment age, family(binomial) link(logit) corr(exchangeable) vce(robust)
xtcorr

vce(robust) requests the sandwich estimator. xtcorr prints the estimated working correlation matrix, which is worth looking at: if an exchangeable structure returns a correlation near zero, the clustering may be negligible, and if it returns something very high your effective sample size is far smaller than the row count suggests.

Sort the data and count the clusters

Two checks before reading any output. Confirm the data is ordered by cluster, and confirm the number of clusters the software reports matches what you expect. Below roughly forty clusters the robust standard errors are unreliable and need a small-sample correction or a different method entirely.

Avoid these

Six mistakes that cost marks

MistakeWhy it matters
Using model-based standard errorsRemoves the robustness that is the entire point of GEE and leaves you relying on the working correlation being right.
Describing a marginal estimate as cluster-specificFor binary outcomes these are genuinely different quantities. At a between-cluster variance of 1.0 they differ by around 17% on the log scale.
Using GEE with few clustersBelow about forty the sandwich estimator understates uncertainty, which defeats the purpose. Use a small-sample correction or a mixed model.
Choosing the correlation structure by p-valuePick it from the design. Trying several and keeping the one that produces significance is p-hacking with extra steps.
Using AIC for model selectionGEE is not a likelihood method, so AIC does not apply. QIC is the quasi-likelihood equivalent.
Ignoring the missing data assumptionStandard GEE needs missing completely at random, stronger than the MAR that mixed models tolerate. With outcome-related dropout it can be biased.

Writing it up

How to report it

Reviewers want evidence that each choice was deliberate. Five sentences usually suffice.

✓State the link function and distribution, and what the clustering variable was.
✓Name the working correlation structure and why it suits the design.
✓Say explicitly that robust standard errors were used, and name any small-sample correction.
✓Report the number of clusters and the observations per cluster, not only the total rows.
✓Describe the estimates as population-averaged, and show the conclusion survives a different correlation structure.

In R this is geepack::geeglm with id and corstr; in Stata xtgee with vce(robust); in SPSS the GEE option within Generalized Linear Models; in SAS PROC GENMOD with a REPEATED statement. If an analysis has already been written up and you want it checked before submission, that is what an independent statistical review covers.

Common questions

Frequently asked questions

What are generalised estimating equations used for?

Fitting regression models when observations are correlated rather than independent, which happens whenever measurements repeat within a person or cluster within a group. GEE produces population-averaged effect estimates with standard errors that remain valid even if the assumed correlation structure is wrong.

What is the difference between GEE and a mixed effects model?

GEE estimates the population-averaged effect and treats clustering as a nuisance. A mixed effects model estimates the cluster-specific effect and models the clustering explicitly. For continuous outcomes the two usually agree; for binary outcomes the GEE odds ratio is pulled towards 1 relative to the mixed model one, and the two answer genuinely different questions.

Which working correlation structure should I choose?

Exchangeable suits most applied work where observations within a cluster have no natural order. AR(1) suits measurements at regular time intervals. Unstructured suits a few fixed time points with many clusters. Independence is valid too and leans entirely on the robust standard errors. Choose it from the design, not by comparing p-values.

Does it matter if I pick the wrong correlation structure?

Much less than people expect. With robust standard errors and a correctly specified mean model, GEE stays consistent and inference stays valid even under serious misspecification. A better structure gives you efficiency, meaning tighter intervals, rather than correctness.

How many clusters does GEE need?

Around forty is the commonly quoted minimum before the robust estimator becomes unreliable. With fewer, use a small-sample correction such as Mancl-DeRouen or Kauermann-Carroll, switch to a mixed effects model, or aggregate to cluster level. The number of clusters matters, not the number of rows.

Can GEE handle missing data?

Only under missing completely at random, which is a stronger requirement than the missing at random condition that mixed models can tolerate. If dropout relates to anything you observed, standard GEE may be biased. Weighted GEE using inverse probability weights addresses this, at the cost of needing a model for the missingness.

Is it generalised or generalized estimating equations?

They are the same method. Generalised is British usage and generalized American; journals follow their own house style and the abbreviation GEE is universal.