For me, Poisson regression has been a nice tool to estimate risk ratios (setting offset to log-number of group size) and rate ratios (setting offset to log-risktime). Recently I came across a situation where the estimates on individual-level data did not agree with the estimates based on aggregated data, when an interaction term was present.
Here is an example in R:
# Full data:
a <- read.table(textConnection("Z X Y t n
m e 0 0.5 1
m e 1 1.5 1
m j 0 1 1
m j 1 0.5 1
n e 0 1 1
n e 0 1 1
n e 0 0.5 1
n j 1 0.5 1"), header = T, sep = " ")
# Aggregated data, grouped by X, Z, and t:
b <- read.table(textConnection("Z X Y t n
m e 0 0.5 1
m e 1 1.5 1
m j 0 1 1
m j 1 0.5 1
n e 0 2 2
n e 0 0.5 1
n j 1 0.5 1"), header = T, sep = " ")
# Aggregated data, grouped by X and Z:
d <- read.table(textConnection("Z X Y t n
m e 1 2 2
m j 1 1.5 2
n e 0 2.5 3
n j 1 0.5 1"), header = T, sep = " ")
Log risk ratios without interaction:
formu <- as.formula("Y ~ X + Z + offset(log(n))")
ma <- glm(formu, poisson, a); mb <- glm(formu, poisson, b); md <- glm(formu, poisson, d)
cbind(ma = coef(ma), mb = coef(mb), md = coef(md))
ma mb md
(Intercept) -1.3862944 -1.3862944 -1.3862944
Xj 1.0986123 1.0986123 1.0986123
Zn -0.4054651 -0.4054651 -0.4054651
df <- data.frame(Z = "n", X = "e", n = 1)
c(ma = predict(ma, df), mb = predict(mb, df), md = predict(md, df))
ma.1 mb.1 md.1
-1.791759 -1.791759 -1.791759
Log risk ratios with an interaction:
formu <- as.formula("Y ~ X*Z + offset(log(n))")
ma <- glm(formu, poisson, a); mb <- glm(formu, poisson, b); md <- glm(formu, poisson, d)
cbind(ma = coef(ma), mb = coef(mb), md = coef(md))
ma mb md
(Intercept) -0.6931472 -6.931472e-01 -6.931472e-01
Xj 0.0000000 4.351168e-15 4.351168e-15
Zn -19.6094379 -1.995601e+01 -2.270805e+01
Xj:Zn 20.3025851 2.064916e+01 2.340120e+01
c(ma = predict(ma, df), mb = predict(mb, df), md = predict(md, df))
ma.1 mb.1 md.1
-20.30259 -20.64916 -23.40120
Log rate ratios without interaction:
formu <- as.formula("Y ~ X + Z + offset(log(t))")
ma <- glm(formu, poisson, a); mb <- glm(formu, poisson, b); md <- glm(formu, poisson, d)
cbind(ma = coef(ma), mb = coef(mb), md = coef(md))
ma mb md
(Intercept) -1.45485965 -1.45485965 -1.45485965
Xj 1.47670839 1.47670839 1.47670839
Zn -0.09041403 -0.09041403 -0.09041403
df <- data.frame(Z = "n", X = "e", t = 1)
c(ma = predict(ma, df), mb = predict(mb, df), md = predict(md, df))
ma.1 mb.1 md.1
-1.545274 -1.545274 -1.545274
Log rate ratios with interaction:
formu <- as.formula("Y ~ X*Z + offset(log(t))")
ma <- glm(formu, poisson, a); mb <- glm(formu, poisson, b); md <- glm(formu, poisson, d)
cbind(ma = coef(ma), mb = coef(mb), md = coef(md))
ma mb md
(Intercept) -0.6931472 -0.6931472 -0.6931472
Xj 0.2876821 0.2876821 0.2876821
Zn -19.3783888 -19.6094379 -22.5257286
Xj:Zn 20.4770011 20.7080502 23.6243409
c(ma = predict(ma, df), mb = predict(mb, df), md = predict(md, df))
ma.1 mb.1 md.1
-20.07154 -20.30259 -23.21888
How to explain the difference of estimates when the regression includes an interaction and how do the interpretations differ?