### Graphs in HLM

```Graphs in HLM
Model setup, Run the analysis before
graphing
• Sector = 0 public school
• Sector = 1 private school
Graph entire model
With level 1 predictor
Here it is the graph
18.61
MATHACH
15.03
11.45
7.87
4.29
-3.76
-2.15
-0.53
SES
1.08
2.69
And the graph
20.01
SECTOR_M = 0
SECTOR_M = 1
MATHACH
15.27
10.53
5.79
1.05
-3.76
-2.15
-0.53
SES
1.08
2.69
What happened if we choose 25th and
75th percentiles?
17.03
MEANSES = -0.296
MEANSES = 0.332
MATHACH
15.04
13.05
11.06
9.07
-1.04
-0.52
-0.01
SES
0.51
1.02
We can choose other options, say,
25th/50th/75th percentiles
The graph with 3 MEANSES levels
17.03
MEANSES = -0.296
MEANSES = 0.037
MEANSES = 0.332
MATHACH
15.04
13.05
11.06
9.07
-1.04
-0.52
-0.01
SES
0.51
1.02
More complicated graph
More complicated graph
17.22
MEANSES
MEANSES
MEANSES
MEANSES
MEANSES
MEANSES
MATHACH
14.86
12.51
10.15
7.79
-1.04
-0.52
-0.01
SES
0.51
1.02
=
=
=
=
=
=
-0.296,SECTOR_M = 0
-0.296,SECTOR_M = 1
0.037,SECTOR_M = 0
0.037,SECTOR_M = 1
0.332,SECTOR_M = 0
0.332,SECTOR_M = 1
Graph level 1 equation
The graph with first 10 groups
(schools)
22.21
MATHACH
17.75
13.29
8.82
4.36
-1.66
-0.87
-0.07
SES
0.72
1.51
What if we choose n=160 schools?
22.89
MATHACH
17.48
12.07
6.67
1.26
-3.27
-1.66
-0.05
SES
1.57
With level 2 predictor: sector
22.89
SECTOR_M = 0
SECTOR_M = 1
MATHACH
17.48
12.07
6.67
1.26
-3.76
-2.15
-0.53
SES
1.08
2.69
21.45
SECTOR_M = 0
SECTOR_M = 1
MATHACH
16.45
11.44
6.43
1.43
-1.66
-0.68
SES
0.30
1.27
Add a level 2 continuous variable
18.40
MEANSES: lower
MEANSES: mid 50%
MEANSES: upper
MATHACH
14.12
9.83
5.55
1.26
-1.66
-0.66
SES
0.35
1.35
Level 1 residual box-whisker
• To examine
distributions of
level-1 residuals.
• Normality
assumption
• Homogeneity of
variance
Level 1 residual box-whisker
17.73
Level-1 Residual
9.09
0.45
-8.19
-16.83
0
3.00
6.00
9.00
12.00
Also could add a level 2 predictor
17.73
SECTOR_M = 0
SECTOR_M = 1
Level-1 Residual
9.09
0.45
-8.19
-16.83
0
3.00
6.00
9.00
12.00
Level-1 residual vs predicted value
Level-1 residual vs predicted value
16.12
8.26
Level-1 Residual
• Observe the
pattern of
residual
scatter
0.41
-7.45
-15.30
5.35
9.18
13.01
16.83
Level-1 Predicted Value
20.66
16.12
SECTOR_M = 0
SECTOR_M = 1
Level-1 Residual
8.26
0.41
-7.45
-15.30
5.35
9.18
13.01
16.83
Level-1 Predicted Value
20.66
One graph per group, multiple graphs
per page
Level-2 EB/OLS coefficient confidence
intervals
• Compare the
estimated
empirical Bayes
(EB) and OLS
estimates of
randomly varying
level-1
coefficients
(intercept and
other
coefficients).
Intercept with level 2 sectors
23.52
SECTOR_M = 0
SECTOR_M = 1
INTERCEPT
18.18
12.83
7.49
2.14
0
40.50
81.00
121.50
162.00
Intercept with level 2 MEANSES
23.52
MEANSES: lower
MEANSES: mid 50%
MEANSES: upper
INTERCEPT
18.18
12.83
7.49
2.14
0
40.50
81.00
121.50
162.00
Slope of SES
4.63
SECTOR_M = 0
SECTOR_M = 1
SES
3.47
2.31
1.15
-0.01
0
40.50
81.00
121.50
162.00
Graph data
Math regressed on SES (10 schools)
26.38
SECTOR_M = 0
SECTOR_M = 1
MATHACH
18.73
11.08
3.43
-4.22
-1.82
-0.94
-0.07
SES
0.80
1.67
One graph per group, multiple graphs
per page
SECTOR_M = 0
SECTOR_M = 1
Longitudinal data
Whole model
(CB- HLM Longitudinal Example)
268.0
GENDER_M = 1
GENDER_M = 2
SUBEN
259.9
251.8
243.6
235.5
0
4.61
9.22
TIME
13.82
18.43
With gender and year (level 2)
268.5
GENDER_M = 1,YEAR_FIR = 2
GENDER_M = 1,YEAR_FIR = 3
GENDER_M = 2,YEAR_FIR = 2
GENDER_M = 2,YEAR_FIR = 3
SUBEN
260.2
251.9
243.7
235.4
0
4.61
9.22
TIME
13.82
18.43
Graph data
312.1
YEAR_FIR: lower
YEAR_FIR: mid 50%
YEAR_FIR: upper
SUBEN
278.8
245.5
212.2
178.9
-1.22
5.49
12.20
TIME
18.91
25.62
```