1. Multilevel Model - A very brief tutorial
Kamarul Imran M
8 December 2015
Kamarul Imran M Multilevel Model - A very brief tutorial 8 December 2015 1 / 12
2. Motivation
You may collect data from groups
These groups may be selected from different levels or hierarchy
The elements of members in a particular group share more similar
features or characteristics.
For example
Level 3 districts
Level 2 schools (school)
Level 1 pupils (case)
Kamarul Imran M Multilevel Model - A very brief tutorial 8 December 2015 2 / 12
6. Random intercept (RI) model
we will fit an RI model using a linear mixed model
model with only 1 covariate (for simplicity) - cohort90
## Loading required package: Matrix
ri1<-lmer(score~cohort90+(1|schoolid),data=mydata,REML=FALSE)
fixef(ri1)
## (Intercept) cohort90
## 30.559151 1.214955
VarCorr(ri1)
## Groups Name Std.Dev.
## schoolid (Intercept) 6.7815
## Residual 14.8084
Kamarul Imran M Multilevel Model - A very brief tutorial 8 December 2015 6 / 12
7. The RI results
On average, the score at baseline was 30.6
On average, with 1 unit increase in cohort, the score increases for 1.22
We will see the plot.
The y axis is the score (dependent)
The x axis is the cohort (covariate=beta1)
Kamarul Imran M Multilevel Model - A very brief tutorial 8 December 2015 7 / 12
8. Each schools have different scores at baseline (SD for intercept=6.8)
Each school has the same slope (beta1=1.215)
cohort90
predscore1
10
20
30
40
50
60
−5 0 5
Kamarul Imran M Multilevel Model - A very brief tutorial 8 December 2015 8 / 12
9. Random slope (RS) model
Each schools have different score at baseline (SD for intercept=6.5)
Each school has the different slope (SD for beta1=0.40)
rs1 <- lmer(score ~ cohort90 + (1 + cohort90 | schoolid),
data = mydata, REML = FALSE)
fixef(rs1)
## (Intercept) cohort90
## 30.609633 1.233903
VarCorr(rs1)
## Groups Name Std.Dev. Corr
## schoolid (Intercept) 6.54660
## cohort90 0.40074 -0.390
## Residual 14.68807
Kamarul Imran M Multilevel Model - A very brief tutorial 8 December 2015 9 / 12
10. Intercept and slope correlation
The average score for schools at baseline = 30.6 (SD=6.5)
The average slope for schools with 1 unit increase in cohort = 1.233
(SD=0.39)
The intercept-slope correlation = -0.390
Negative correlation means
Schools with lower baseline score have higher slope
Schools with higher baseline score have lower slope
Kamarul Imran M Multilevel Model - A very brief tutorial 8 December 2015 10 / 12
11. xyplot(predscore ~ cohort90, data = mydata
, groups = schoolid, type = c("p","l"), col = "blue",lwd=0.2)
cohort90
predscore
10
20
30
40
50
−5 0 5
Kamarul Imran M Multilevel Model - A very brief tutorial 8 December 2015 11 / 12
12. Summary
Multilevel data needs special treatment
Random variations between members in different levels
variations at baseline
variations for slope
Linear mixed model provides more useful information than linear
regression
Linear mixed model more accurately reflects our data than linear
regression
THANKS
Kamarul Imran M Multilevel Model - A very brief tutorial 8 December 2015 12 / 12