文档介绍:Multilevel Analysis
(ver. )
Oscar Torres-Reyna
Data Consultant
******@
/
PU/DSS/OTR
Motivation
Use multilevel model whenever your data is grouped (or nested) in more than
one category (for example, states, countries, etc).
Multilevel models allow:
• Study effects that vary by entity (or groups)
• Estimate group level averages
Some advantages:
• Regular regression ignores the average variation between entities.
• Individual regression may face sample problems and lack of
generalization
2
PU/DSS/OTR
Variation between entities
use
bysort school: egen y_mean=mean(y)
twoway scatter y school, msize(tiny) || connected y_mean school, connect(L)
clwidth(thick) clcolor(black) mcolor(black) msymbol(none) || , ytitle(y)
40
20
y
0
-20
-40
0 20 40 60
school
Score y_mean 3
PU/DSS/OTR
statsby inter=_b[_cons] slope=_b[x1], by(school) saving(ols, replace): regress y x1
sort school
merge school using ols
drop _merge Individual regressions
gen yhat_ols = inter + slope*x1
sort school x1 (no-pooling approach)
separate y, by(school)
separat