Pemodelan MLM
Model Null
Estimasi Model Null
# load package for MLM
library(lme4)Loading required package: Matrix
Attaching package: 'Matrix'
The following objects are masked from 'package:tidyr':
expand, pack, unpack
library(sjPlot)Warning: package 'sjPlot' was built under R version 4.1.3
#refugeeswelcome
# empty multilevel model
m0 <- lmer(math~ 1 + (1 | CNTSCHID), data = skor)
# details of results
# summary(m0)Model Null
tab_model(m0)| math | |||
|---|---|---|---|
| Predictors | Estimates | CI | p |
| (Intercept) | 398.31 | 369.99 – 426.63 | <0.001 |
| Random Effects | |||
| σ2 | 2613.86 | ||
| τ00 CNTSCHID | 4088.60 | ||
| ICC | 0.61 | ||
| N CNTSCHID | 20 | ||
| Observations | 733 | ||
| Marginal R2 / Conditional R2 | 0.000 / 0.610 | ||
Interpretasi Model Null
398.31 adalah intercept atau nilai yang diharapkan (i.e. rata-rata) dari skor matematika pada semua sekolah dan siswa.
4089 adalah varisi sekolayh dalam skor matematika
2614 adalah individual level variation dalam skor matematika
Distribusi per sekolah
# save predicted scores
skor$m0 <- predict(m0)
# graph with predicted country level support for immigration
skor %>%
ggplot(aes(math, m0, color = CNTSCHID, group = CNTSCHID)) +
geom_smooth(se = F, method = lm) +
geom_jitter()+
theme_bw() +
theme(axis.text.x = element_blank(),
axis.ticks = element_blank()) +
labs(x = "", y = "Skor Matematika", color = "Sekolah")`geom_smooth()` using formula = 'y ~ x'

Variasi di tingkat sekolah dapat dilihat seberapa panjang garis. Jika pendek relatif sama, sedangkan jika panjang, relatif berbeda. Variasi tingkat individu adalah ringkasan perbedaan antara setiap individu dilihat jarak dari titik ke garis.
Interpretasi ICC Model Null
ICC<-4089/(4089+2614)
print(ICC)[1] 0.6100254
- 61% variasi dalam skor matematika berasal dari sekolah atau 39% disebabkan oleh karakteristik siswa.
- jika kita memilih siswa dari sekolah yang sama, korelasi yang diharapkan dalam skor matematika adalah 0,61.
Sebaran intercept
## Lattice
# dotplot using lattice package
library(lattice)
qqmath(ranef(m0, condVar = TRUE))$CNTSCHID

Dalam grafik ini setiap titik mewakili suatu sekolah dan garis di sekitarnya adalah interval kepercayaan.
Random Intercept
Estimasi Random Intercept
# random intercept with a control variable
m1 <- lmer(math ~ 1 + growth + (1 | CNTSCHID), data = skor)
summary(m1)Linear mixed model fit by REML ['lmerMod']
Formula: math ~ 1 + growth + (1 | CNTSCHID)
Data: skor
REML criterion at convergence: 7904.4
Scaled residuals:
Min 1Q Median 3Q Max
-4.0598 -0.6458 0.0304 0.6155 3.1288
Random effects:
Groups Name Variance Std.Dev.
CNTSCHID (Intercept) 3930 62.69
Residual 2573 50.73
Number of obs: 733, groups: CNTSCHID, 20
Fixed effects:
Estimate Std. Error t value
(Intercept) 421.196 15.500 27.17
growth -8.213 2.275 -3.61
Correlation of Fixed Effects:
(Intr)
growth -0.409
Estimasi Random Intercept
library(sjPlot)
tab_model(m1)| math | |||
|---|---|---|---|
| Predictors | Estimates | CI | p |
| (Intercept) | 421.20 | 390.77 – 451.63 | <0.001 |
| growth | -8.21 | -12.68 – -3.75 | <0.001 |
| Random Effects | |||
| σ2 | 2573.19 | ||
| τ00 CNTSCHID | 3929.81 | ||
| ICC | 0.60 | ||
| N CNTSCHID | 20 | ||
| Observations | 733 | ||
| Marginal R2 / Conditional R2 | 0.007 / 0.607 | ||
ICC Random Intercept
ICC2=3930/(3930+2573)
print(ICC2)[1] 0.6043365
Interpretasi Random Intercept
- Bertambahnya 1 poin growth mindset, skor matematika meningkat sebesar 8,21.
- ICC sedikit lebih kecil dibandingkan dengan model sebelumnya.
- Growth mindset dapat sedikit menjelaskan variasi skor matematika baik di tingkat siswa maupun sekolah.
Sebaran Model 1 (Random Intercept)
# save predicted scores
skor$m1 <- predict(m1)
# plot lines based on our model
skor %>%
ggplot(aes(growth, m1, color = CNTSCHID, group = CNTSCHID)) +
geom_smooth(se = F, method = lm) +
geom_jitter()+
theme_bw() +
labs(x = "Growth Mindset",
y = "Skor Matematika",
color = "Sekolah")`geom_smooth()` using formula = 'y ~ x'

Random Slope
Intuisi Random Slope
Model sebelumnya membuat asumsi bahwa pengaruh growth mindset adalah sama di semua sekolah (itu sebabnya garisnya paralel).
Bagaimana jika satu skor growth mindset lebih “efektif” di beberapa sekolah daripada yang lain dalam meningkatkan skor matematika.
Pada titik ini random slope diperlukan.
Kita memperoleh koefisien baru yang menggambarkan perbedaan antar sekolah dalam pengaruh growth mindset terhadap skor matematika.
Estimasi Random Slope
# model with random slope
m2 <- lmer(math ~ 1 + growth +
(1 + growth | CNTSCHID),
data = skor)
# print results
summary(m2)Linear mixed model fit by REML ['lmerMod']
Formula: math ~ 1 + growth + (1 + growth | CNTSCHID)
Data: skor
REML criterion at convergence: 7900.8
Scaled residuals:
Min 1Q Median 3Q Max
-4.0670 -0.6649 0.0295 0.6340 3.3370
Random effects:
Groups Name Variance Std.Dev. Corr
CNTSCHID (Intercept) 5277.12 72.644
growth 73.29 8.561 -0.55
Residual 2525.62 50.256
Number of obs: 733, groups: CNTSCHID, 20
Fixed effects:
Estimate Std. Error t value
(Intercept) 420.311 17.569 23.924
growth -8.054 2.984 -2.699
Correlation of Fixed Effects:
(Intr)
growth -0.606
Estimasi Random Slope
tab_model(m2, show.icc = TRUE)| math | |||
|---|---|---|---|
| Predictors | Estimates | CI | p |
| (Intercept) | 420.31 | 385.82 – 454.80 | <0.001 |
| growth | -8.05 | -13.91 – -2.20 | 0.007 |
| Random Effects | |||
| σ2 | 2525.62 | ||
| τ00 CNTSCHID | 5277.12 | ||
| τ11 CNTSCHID.growth | 73.29 | ||
| ρ01 CNTSCHID | -0.55 | ||
| ICC | 0.61 | ||
| N CNTSCHID | 20 | ||
| Observations | 733 | ||
| Marginal R2 / Conditional R2 | 0.007 / 0.616 | ||
Interpretasi Random Slope
- Fixed effect growth mindset mengecil dibanding model 1 dan kita mempunyai koefisien baru random effect.
- Varian random slope untuk tahun pendidikan adalah 73.29.
Sebaran Random Slope
skor$m2 <- predict(m2)
# visualize the predictions based on our model
skor %>%
ggplot(aes(growth, m2)) +
geom_smooth(se = F, method = lm, size = 2) +
geom_jitter()+
stat_smooth(aes(color = CNTSCHID, group = CNTSCHID),
geom = "line", alpha = 0.4, size = 1) +
theme_bw() +
guides(color = F) +
labs(x = "Growth Mindset",
y = "Skor Matematika",
color = "Sekolah")Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
i Please use `linewidth` instead.
Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as
of ggplot2 3.3.4.
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 2.5851e-017
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 1.0302
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 2.5851e-017
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 1.0302
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 3.6547e-017
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 4.0602
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 3.6547e-017
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 4.0602
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 1.3023e-016
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 1.0302
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 1.3023e-016
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 1.0302
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 2.5259e-017
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 1.0302
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 2.5259e-017
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 1.0302
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 1.2498e-016
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 4.0602
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 1.2498e-016
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 4.0602
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 9.4805e-017
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 1.0302
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 9.4805e-017
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 1.0302
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 1.99
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 1.01
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 0
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 1.0201
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
1.99
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius 1.01
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 0
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 1.0201
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 2.293e-016
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 4.0602
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 2.293e-016
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 4.0602
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 1.4793e-016
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 1.0302
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 1.4793e-016
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 1.0302
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 4.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 1.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 0
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 1
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
4.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
1.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 0
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 1
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 9.2674e-017
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 4.0602
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 9.2674e-017
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 4.0602
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 1.5078e-016
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 4.0602
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 1.5078e-016
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 4.0602
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 3.5034e-017
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 4.0602
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 3.5034e-017
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 4.0602
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 0
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 1.0302
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 0
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 1.0302
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 1.5418e-016
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 1.0302
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 1.5418e-016
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 1.0302
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 2.6119e-016
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 4.0602
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 2.6119e-016
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 4.0602
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 2.6258e-016
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 4.0602
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 2.6258e-016
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 4.0602
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 9.0578e-017
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 4.0602
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 9.0578e-017
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 4.0602
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 3.3763e-017
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 4.0602
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 3.3763e-017
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 4.0602
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : pseudoinverse used at 0.985
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : neighborhood radius 2.015
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : reciprocal condition number 8.7635e-017
Warning in simpleLoess(y, x, w, span, degree = degree, parametric =
parametric, : There are other near singularities as well. 4.0602
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
0.985
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
2.015
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
number 8.7635e-017
Warning in predLoess(object$y, object$x, newx = if
(is.null(newdata)) object$x else if (is.data.frame(newdata))
as.matrix(model.frame(delete.response(terms(object)), : There are other near
singularities as well. 4.0602

Fixed effect yaitu -8.054, tetapi setiap sekolah memiliki slope yang beragam.
Sebaran intercept
# another way to see random effect
qqmath(ranef(m2, condVar = TRUE))$CNTSCHID

Grafik menunjukkan bagaimana pengaruh growth mindset bervariasi di setiap sekolah.
Random Effects
# yet another way to look at the random effects
# save coefficients
coefs_m2 <- coef(m2)
# print random effects and best line
coefs_m2$CNTSCHID %>%
mutate(CNTSCHID = rownames(coefs_m2$CNTSCHID)) %>%
ggplot(aes(growth, `(Intercept)`, label = CNTSCHID)) +
geom_point() +
geom_smooth(se = F, method = lm) +
geom_label(nudge_y = 0.15, alpha = 0.5) +
theme_bw() +
labs(x = "Slope", y = "Intercept")`geom_smooth()` using formula = 'y ~ x'
Warning: The following aesthetics were dropped during statistical transformation: label
i This can happen when ggplot fails to infer the correct grouping structure in
the data.
i Did you forget to specify a `group` aesthetic or to convert a numerical
variable into a factor?

Interpretasi random effects
Grafik menunjukkan bahwa beberapa sekolah memiliki memiliki skor matematika yang tinggi tetapi memiliki efek yang rendah pada outcome dan sebaliknya.
Garis biru mewakili hubungan antara intersep acak dan kemiringan dengan koefisien sebesar 0.6. Hal ini menunjukkan bahwa semakin kecil fixed mindset, semakin tinggi skor matematika.
Refleksi untuk penelitian lanjut
Penerapan
- Eksperimen
- Meta analisis
- Survey
- Multilevel SEM
- Penelitian longitudinal
Refleksi akhir
- Analisis multilevel membantu mengurangi kesalahan dalam pembuatan kesimpulan
- Pentingnya memperhatikan konteks dalam studi psikologi
- Pemanfaatan data skala besar untuk penelitian psikologi
- Dalam pembuatan kebijakan analisis multilevel dapat digunakan untuk kebijakan yang lebih presisi.