Generalized Estimating Equations Overview
Generalized Estimating Equations Overview
1
These course slides should not be reproduced nor used by others (without
permission).
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 1 / 52
First...
Textbook
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 2 / 52
Lecture Outline I
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 3 / 52
Chapter 5: Generalized Estimating Equations (GEE)
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 4 / 52
Chapter 5: Generalized Estimating Equations (GEE)
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 5 / 52
Chapter 5: Generalized Estimating Equations (GEE) Generalized Estimating Equations (GEE)
Overview of GEE
Generalized Estimating Equations (GEE) is a statistical method used to
estimate the parameters of a generalized linear model with correlated data,
particularly in longitudinal or clustered settings. The key purpose of GEE
is to model the population-averaged response, focusing on the average
eect of a predictor across the entire population, while accounting for the
correlation structure within the data. It accounts for the correlation within
subjects or clusters but doesn't
Prof. explicitly
dr. M. [Link]
Karimthe subject-specic eects.
Instead, it uses a "working" correlation structure (e.g., independence,
exchangeable, or autoregressive) as an approximation. GEE can be used
for non-normal data, such as binary (logistic regression) or count data
(Poisson regression).
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 6 / 52
Chapter 5: Generalized Estimating Equations (GEE) Generalized Estimating Equations (GEE)
Model Specication
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 7 / 52
Chapter 5: Generalized Estimating Equations (GEE) Likelihood Function in GEE
where,
n
L(β) = ∑ log f (Yi ; µi , φ)
i=1
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 8 / 52
Chapter 5: Generalized Estimating Equations (GEE) Likelihood Function in GEE
Examples
n
L(β) = ∑ [Yi log(µi ) + (ni − Yi ) log(1 − µi )]
i=1
n
n 1
L(β) = − log(2πσ 2 ) − ∑(Yi − µi )
2
2 2σ 2 i=1
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 9 / 52
Chapter 5: Generalized Estimating Equations (GEE) Likelihood Function in GEE
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 10 / 52
Chapter 5: Generalized Estimating Equations (GEE) Likelihood Function in GEE
n
∂L ∂µi
∝∑ (Yi − µi )
∂β i=1 ∂β
Interpretation:
The derivative captures how the likelihood changes with respect to
the parameters β.
(Yi − µi ): Deviation of observed values from expected values.
∂µi
∂β : Change in expected values as parameters vary.
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 11 / 52
Chapter 5: Generalized Estimating Equations (GEE) Likelihood Function in GEE
Score Function
The estimating equations arise from setting the score function to zero:
n
∂L
U(β) = ∑ =0
i=1 ∂β
n
∂L ∂µi
∝∑ (Yi − µi )
∂β i=1 ∂β
3 Normalization by Variance:
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 12 / 52
Chapter 5: Generalized Estimating Equations (GEE) Likelihood Function in GEE
∂µi 1 −1 T ′
Zi = = g (Xi β) Xi
∂β φ
where:
Prof. dr. M. R. Karim
g −1 is the inverse link function.
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 13 / 52
Chapter 5: Generalized Estimating Equations (GEE) Likelihood Function in GEE
n
U(β) = ∑ ZTi Vi−1 (Yi − µi ) = 0
i=1
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 14 / 52
Chapter 5: Generalized Estimating Equations (GEE) GEE Estimation
GEE Estimation
n
U(β) = ∑ ZTi Vi−1 (Yi − µi ) = 0
i=1
Prof. dr. M. R. Karim
where:
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 15 / 52
Chapter 5: Generalized Estimating Equations (GEE) GEE Estimation
Functional Form of Vi
2
⎛σ 0 0 ⋯ 0⎞
Prof. dr. R.2 Karim
⎜ 0M. σ 0 ⋯ 0⎟
⎜ ⎟
Vi =σ I=⎜0 0 σ ⋯ 0⎟
2 ⎜ 2
⎟
⎜ ⋮ ⋮ ⋮ ⋱ ⋮ ⎟
⎜ ⎟
⎝ 0 0 0 ⋯ σ2⎠
Working Independence
Initial parameter estimates are obtained by tting a GLM.
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 16 / 52
Chapter 5: Generalized Estimating Equations (GEE) GEE Estimation
⎛1 ρ ρ ⋯ ρ⎞
⎜ρ 1 ρ ⋯ ρ⎟
⎜ ⎟
Vi = σdr.⎜ρM. ρR.
Prof.
2⎜
Karim
1 ⋯ ρ⎟⎟
⎜⋮ ⋮ ⋮ ⋱ ⋮⎟
⎜ ⎟
⎝ρ ρ ρ ⋯ 1⎠
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 17 / 52
Chapter 5: Generalized Estimating Equations (GEE) GEE Estimation
⎛ 1 ρ ρ2 ⋯ ρn−1 ⎞
⎜ ρ
⎜ 1 ρ ⋯ ρn−2 ⎟
⎟
Vi 2⎜
= σProf. 2
⎜ ρ dr. M.ρ R. Karim
1 ⋯ ρn−3 ⎟
⎟
⎜ ⋮ ⋮ ⋮ ⋱ ⋮ ⎟
⎜ ⎟
⎝ρn−1 ρn−2 ρn−3 ⋯ 1 ⎠
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 18 / 52
Chapter 5: Generalized Estimating Equations (GEE) GEE Estimation
2
⎛ σ1 σ12 σ13 ⋯ σ1n ⎞
⎜σ21
⎜ σ22 σ23 ⋯ σ2n ⎟ ⎟
Vi Prof.
=⎜⎜σ31dr. σM.
32
2
R.σKarim
3 ⋯ σ3n ⎟
⎟
⎜ ⋮ ⋮ ⋮ ⋱ ⋮ ⎟
⎜ ⎟
⎝σn1 σn2 σn3 ⋯ σn2 ⎠
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 19 / 52
Chapter 5: Generalized Estimating Equations (GEE) GEE Estimation
2
⎛σ ρ1 ρ2 ⋯ ρn−1 ⎞
2
⎜ ρ1 σ ρ1 ⋯ ρn−2 ⎟
⎜ ⎟
Vi =Prof.
⎜ ρ2 dr. ρM.
⎜ 1 R. σ
2
Karim⋯ ρn−3 ⎟
⎟
⎜ ⋮ ⋮ ⋮ ⋱ ⋮ ⎟
⎜ ⎟
⎝ρn−1 ρn−2 ρn−3 ⋯ σ 2 ⎠
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 20 / 52
Chapter 5: Generalized Estimating Equations (GEE) GEE Estimation
Correlation Structure
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 21 / 52
Chapter 5: Generalized Estimating Equations (GEE) GEE Estimation
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 22 / 52
Chapter 5: Generalized Estimating Equations (GEE) GEE Estimation
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 23 / 52
Chapter 5: Generalized Estimating Equations (GEE) GEE Estimation
n −1 n n −1
̂ = (∑ ZT V−1 Zi )
S(β) i i (∑ Z T
i V Ui U V Z
−1
i
T
i
−1
i i ) (∑ Z V Z
T
i
−1
i i)
i=1 i=1 i=1
where
Ui = Yi − µi
Prof. dr. M. R. Karim
Role in Robust Variance Estimation
The term Ui captures the dierence between the observed and expected
values, reecting how the data deviate from the estimated model.
Importance:
It adjusts the variance estimation to account for potential correlation
in the data.
Sandwich Estimator
The sandwich estimator for the variance of an estimator ̂
β is expressed as:
̂
Var(β) ≈ H−1 DH−1
Where:
H: Hessian matrix (information matrix):
n
H = ∑ ZTi Vi−1 Zi
Prof. dr. i=
M. 1 R. Karim
Running GEE in R
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 26 / 52
Chapter 5: Generalized Estimating Equations (GEE) Selecting the Best Correlation Matrix for GEE
2. Model Fitting
Fit GEE models using dierent correlation structures.
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 27 / 52
Chapter 5: Generalized Estimating Equations (GEE) Selecting the Best Correlation Matrix for GEE
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 28 / 52
Chapter 5: Generalized Estimating Equations (GEE) Selecting the Best Correlation Matrix for GEE
6. Practical Considerations
Prof. dr. M. R. Karim
Computational feasibility: Unstructured models can be intensive.
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 29 / 52
Chapter 5: Generalized Estimating Equations (GEE) Selecting the Best Correlation Matrix for GEE
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 30 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 8
Practical Problem - 8
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 31 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 8
That is,
1 if SP-ratio > 0.4
yi = {
0 if SP-ratio ≤ 0. 4.
The time variable days is categorized in seasons as follows (1 referring to
winter, etc):
⎧
⎪ 1 0≤ days ≤ 90
⎪
⎪
⎪
⎪ 2 91≤ days ≤ 181
xi = ⎨
⎪
⎪ 3 182 ≤ days ≤ 273
Prof.
⎪
⎪ dr. M. R. Karim
⎪
⎩ 4 274 ≤ days ≤ 365.
(a) Fit a logistic regression model for yi with season and weight as
explanatory variables. Select a best tting model and interpret.
(b) Repeat exercise (a), but now taking the clustered nature of the data
(herds as clusters) into account. (hints: you can use GEE).
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 32 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 8
R Code
# Load necessary libraries
library(geepack)
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 33 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 8
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 34 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 8
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 35 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 8
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 36 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 9
Practical Problem - 9
You are provided with a dataset ( [Link]) for a Generalized
Estimating Equations (GEE) analysis. The dataset consists of repeated
measures from 100 patients, with data collected at 5 dierent time points.
The key variables in the dataset are:
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 37 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 9
3 [Link].
Interpret your coecients theM. R. Karim
context of the dataset. What do
they imply about the relationship between the predictors and the
binary response?
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 38 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 9
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 39 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 10
Practical Problem - 10
The dataset ([Link]) used in this analysis consists of information
collected from patients visiting multiple clinics. The variables in the
dataset are as follows:
Number_of_Visits:Prof.
[Link]. R. Karim
doctor visits made by each patient
over a year (count data).
The study aims to assess the eect of the treatment on the number of
doctor visits while controlling for age and gender. The data exhibits a
hierarchical structure, with patients nested within clinics.
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 40 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 10
4 Model Diagnostics
1 Discuss the implications of using an exchangeable correlation structure
in the GEE model. What does this assumption imply about the data?
2 If you suspected that the correlation structure might not be
exchangeable, suggest an alternative structure and explain your
reasoning.
5 Visualization
1 Create a boxplot to compare the number of visits between the Control
and Treatment groups.
Prof. Interpret
dr. M. [Link]
results.
2 Generate a scatter plot to visualize the relationship between age and
the number of visits. Discuss any patterns you observe.
6 Advanced Analysis
1 If you wanted to explore the eect of an additional variable (e.g.,
socioeconomic status) on the number of visits, how would you modify
the existing model? Describe the steps you would take.
2 Discuss potential confounding variables in this study and how you
would control for them in your analysis.
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 42 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 10
# 1. Descriptive Statistics
# a. Mean and standard deviation of number of visits for each
treatment group
summary_stats <- aggregate(Number_of_Visits ~ Treatment_Group,
data = GEECount, Prof. dr. M. R. Karim
# b. Histogram of ages
ggplot(GEECount, aes(x = Age)) +
geom_histogram(binwidth = 2, fill = "blue", color = "black",
alpha = 0.7) +
labs(title = "Distribution of Ages", x = "Age", y = "Frequency")
+ theme_minimal()
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 43 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 10
# 2. Statistical Modeling
# a. Fit the GEE model
gee_model <- geeglm(Number_of_Visits ~ Treatment_Group + Age +
Gender, data = GEECount, id = Clinic_ID, family =
poisson(link = "log"), corstr = "exchangeable")
Prof. dr. M. R. Karim
summary(gee_model)
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 44 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 10
# 3. Hypothesis Testing
# a. Null and alternative hypotheses
# H0: Treatment has no effect on the number of visits.
# H1: Treatment has a significant effect on the number of visits.
# 4. Model Diagnostics
# Discuss implications (this would be a written answer)
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 45 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 10
# 5. Visualization
# a. Boxplot for number of visits by treatment group
ggplot(GEECount, aes(x = Treatment_Group, y = Number_of_Visits))
+ geom_boxplot(fill = "lightgreen") +
labs(title = "Number of Visits by Treatment Group", x =
"Treatment Group", y = "Number of Visits") +
theme_minimal()
# 6. Advanced Analysis
# Discuss potential additional variable (written answer)
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 46 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 11
Practical Problem - 11
Worldwide Salmonellosis, the illness from Salmonella infection, is the most
frequently occurring zoonoses, which is an infectious disease directly or
indirectly transmitted between animals and humans. Of the reported
Salmonella infections 26% of these are likely to be due to transmission of
the pathogen via pork. MAP is determined by the sample to positive (SP)
ratio for each sample, where S = optical density of the sample optical
density of the negative. SP-ratios normally cover a range between 0 and 4,
Prof. dr. M. R. Karim
but even higher values can be observed. The dataset
[Link] contains a random subset of a (very) large
sample.
The variables are dened as: weight, SP, days. he main objective is to
examine the dependency of the SP-ratios on the covariates weight and
time. The time variable days is categorized in seasons as follows (1
referring to winter, etc):
⎧
⎪ 1 0≤ days ≤ 90
⎪
⎪
⎪
⎪ 2 91≤ days ≤ 181
xi = ⎨
⎪
⎪ 3 182 ≤ days ≤ 273
⎪
⎪
⎪
⎩ 4 274 ≤ days ≤ 365.
Prof. dr. M. R. Karim
We treat all variables (SP-ratio, sampling time, and weight) as categorical
variables. As the infection status of an animal with SP-ratio between 0.5
and 1 is doubtful, we include a middle category inconclusive leading to
the trinomial response
⎧
⎪ 1 SP-ratio ≤ 0.4
⎪
⎪
yi = ⎨ 2 0 .4 < SP-ratio ≤ 0.9
⎪
⎪
⎪
⎩ 3 SP-ratio > 0.9
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 48 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 11
(i). Fit multicategory logit models for yi with season and weight as
explanatory variables. Which model(s) do you prefer and why?
(ii). Repeat exercise (a), but now taking the clustered nature of the data
Prof. dr. M. R. Karim
(herds as clusters) into account. (hints: use GLMM model).
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 49 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 11
Solution of Problem 11
# Load necessary libraries
library(tidyverse)
library(nnet) # For the multinom function
library(lme4) # For fitting GLMM
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 50 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 11
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 51 / 52
Chapter 5: Generalized Estimating Equations (GEE) Practical Problem - 11
Prof. Dr. Md. Rezaul Karim, Department of Statistics and Data Science, JU. August 14, 2025 52 / 52