# Predicting individual-level outcome with only group-level data

Suppose I have summary data from a number of different classrooms, and I want to model a binary outcome (pass/fail) for individual students. I have no individual-level data. I have some classroom characteristics (treatment), and some individual characteristics summarized to the classroom level (gpa).

library(data.table)

dt_school <- fread(
'classroom students  gpa teacher pass_rate
A             1000 3.20       0      0.84
B             5000 3.00       0      0.86
C              500 3.25       0      0.91
D              200 3.18       1      0.90
E            10000 3.05       1      0.88
F             2000 3.02       1      0.92'
)


So I use the pass rate to expand the data out:

dt_schoolPF <- rbind(
dt_school[, .(pass = 1,
classroom,
students = students * pass_rate,
gpa,
teacher)],
dt_school[, .(pass = 0,
classroom,
students = students * (1 - pass_rate),
gpa,
teacher)]
)

dt_schoolPF

#     pass classroom students  gpa teacher
#  1:    1         A      840 3.20       0
#  2:    1         B     4300 3.00       0
#  3:    1         C      455 3.25       0
#  4:    1         D      180 3.18       1
#  5:    1         E     8800 3.05       1
#  6:    1         F     1840 3.02       1
#  7:    0         A      160 3.20       0
#  8:    0         B      700 3.00       0
#  9:    0         C       45 3.25       0
# 10:    0         D       20 3.18       1
# 11:    0         E     1200 3.05       1
# 12:    0         F      160 3.02       1


Then I estimate a logit model:

fit <- glm(pass ~ gpa + teacher,
weights = students,
data = dt_schoolPF,
family = binomial)
summary(fit)


This feels wrong, but I can't quite say why. I would expect students' GPAs to be related to the outcome within classrooms, and possibly to other covariates (not shown). So it seems the aggregation of GPA to the classroom level simply introduces ommitted variable bias to those covariates, to the extent that the classroom GPA does not measure individuals' GPAs?

Under what conditions would it be necessary to consider the nested nature of the data?

• Doesn't your model predict that all individuals in the same class will pass (or all individuals will fail)? Indeed, for each class, you will either get pass = 1 (all individuals pass) or pass = 0 (all individuals fail). I doubt this would be of any use to you in practical terms. – Isabella Ghement Mar 30 '19 at 12:23

## 1 Answer

That is a surprisingly difficult problem due to the ecological fallacy.

• This should really be a comment. Could you add more detail or an example in order flesh out the answer? – Demetri Pananos Feb 24 at 17:10