This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Cmd+Shift+Enter.
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Cmd+Option+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Cmd+Shift+K to preview the HTML file).
#Load packages
library(haven)
library(tidyverse)
library(lme4)
library(lmerTest)
#load dataset
projectSTAR <- haven::read_dta("projectSTAR.dta")
glimpse(projectSTAR)
Rows: 6,325
Columns: 27
$ stdntid <dbl> 10001, 10133, 10246, 10263, 10266, 10275, 10281, 10282, 10285, 10286, 10287, 1028…
$ race <dbl+lbl> 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1,…
$ gender <dbl+lbl> 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1,…
$ FLAGSGK <dbl+lbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
$ flaggk <dbl+lbl> 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1,…
$ gkclasstype <dbl+lbl> 3, 3, 3, 1, 2, 3, 1, 3, 1, 2, 3, 3, 2, 3, 3, 3, 1, 2, 3, 3, 2, 1, 1, 3, 2, 1,…
$ gkschid <dbl> 169229, 169280, 218562, 205492, 257899, 161176, 189382, 189382, 201449, 230612, 1…
$ gksurban <dbl+lbl> 2, 2, 4, 2, 3, 3, 2, 2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 1, 2, 3, 1, 4,…
$ gktchid <dbl> 16922904, 16928003, 21856202, 20549204, 25789904, 16117602, 18938204, 18938203, 2…
$ gktgen <dbl+lbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,…
$ gktrace <dbl+lbl> 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, …
$ gkthighdegree <dbl+lbl> 2, 2, 3, 2, 3, 2, 3, 3, 3, 3, 2, 2, 3, 2, 2, 2, 2, 2, 2, …
$ gktcareer <dbl+lbl> 4, 4, 4, 4, 4, NA, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, …
$ gktyears <dbl> 5, 7, 8, 3, 12, 2, 7, 14, 4, 6, 11, 16, 12, 5, 17, 10, 6, 10, 13, 9, 18, 1, 7, 13…
$ gkclasssize <dbl> 24, 22, 17, 17, 24, 24, 13, 24, 14, 23, 23, 22, 20, 24, 23, 27, 17, 24, 22, 23, 2…
$ gkfreelunch <dbl+lbl> 2, 2, 2, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 1,…
$ gkrepeat <dbl+lbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
$ gkspeced <dbl+lbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,…
$ gkspecin <dbl+lbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2,…
$ gkpresent <dbl> 161, 175, 132, 178, 170, 94, 160, 154, 172, 95, 163, 172, 180, 149, 173, NA, 160,…
$ gkabsent <dbl> 19, 5, 28, 2, 10, 3, 2, 7, 8, 2, 17, 8, 0, 31, 7, NA, 20, 7, 2, 19, 24, 0, 8, 9, …
$ gktreadss <dbl> NA, 427, 450, 483, 456, 411, 443, 448, 463, 472, 428, 545, 408, 422, 472, NA, 437…
$ gktmathss <dbl> NA, 478, 494, 513, 513, 468, 473, 449, 520, 536, 484, 626, 454, 439, 528, NA, 463…
$ gktlistss <dbl> NA, 509, 549, 554, 520, 571, 595, 540, 565, 595, NA, 622, 474, 536, 578, NA, 554,…
$ gkwordskillss <dbl> NA, 418, 444, 431, 468, 396, 444, 444, 480, 486, 423, 524, 410, 423, 458, NA, 427…
$ gkmotivraw <dbl> 23, 24, 28, 27, 25, 24, NA, NA, 26, 27, 24, 24, 23, 28, 24, NA, 26, 25, NA, 26, 2…
$ gkselfconcraw <dbl> 52, 53, 56, 61, 54, 55, NA, NA, 52, 61, 55, 49, 49, 59, 50, NA, 58, 45, NA, 55, 5…
#figure out coding scheme & variables
str(projectSTAR)
tibble [6,325 × 27] (S3: tbl_df/tbl/data.frame)
$ stdntid : num [1:6325] 10001 10133 10246 10263 10266 ...
..- attr(*, "label")= chr "STUDENT ID"
..- attr(*, "format.stata")= chr "%10.0g"
$ race : dbl+lbl [1:6325] 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1...
..@ label : chr "STUDENT RACE/ETHNICITY"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:6] 1 2 3 4 5 6
.. ..- attr(*, "names")= chr [1:6] "WHITE" "BLACK" "ASIAN" "HISPANIC" ...
$ gender : dbl+lbl [1:6325] 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2...
..@ label : chr "STUDENT GENDER"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:2] 1 2
.. ..- attr(*, "names")= chr [1:2] "MALE" "FEMALE"
$ FLAGSGK : dbl+lbl [1:6325] 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
..@ label : chr "IN STAR IN KINDERGARTEN"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:2] 0 1
.. ..- attr(*, "names")= chr [1:2] "NO" "YES"
$ flaggk : dbl+lbl [1:6325] 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1...
..@ label : chr "ACHIEVEMENT DATA AVAILABLE GRADE K"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:2] 0 1
.. ..- attr(*, "names")= chr [1:2] "NO" "YES"
$ gkclasstype : dbl+lbl [1:6325] 3, 3, 3, 1, 2, 3, 1, 3, 1, 2, 3, 3, 2, 3, 3, 3, 1, 2, 3, 3, 2, 1, 1, 3, 2, 1, 1...
..@ label : chr "CLASSROOM TYPE KINDERGARTEN"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:3] 1 2 3
.. ..- attr(*, "names")= chr [1:3] "SMALL CLASS" "REGULAR CLASS" "REGULAR + AIDE CLASS"
$ gkschid : num [1:6325] 169229 169280 218562 205492 257899 ...
..- attr(*, "label")= chr "KINDERGARTEN SCHOOL ID"
..- attr(*, "format.stata")= chr "%10.0g"
$ gksurban : dbl+lbl [1:6325] 2, 2, 4, 2, 3, 3, 2, 2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 2, 1, 2, 3, 1, 4, 2...
..@ label : chr "SCHOOL URBANICITY KINDERGARTEN"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:4] 1 2 3 4
.. ..- attr(*, "names")= chr [1:4] "INNER CITY" "SUBURBAN" "RURAL" "URBAN"
$ gktchid : num [1:6325] 16922904 16928003 21856202 20549204 25789904 ...
..- attr(*, "label")= chr "KINDERGARTEN TEACHER ID"
..- attr(*, "format.stata")= chr "%10.0g"
$ gktgen : dbl+lbl [1:6325] 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2...
..@ label : chr "TEACHER GENDER KINDERGARTEN"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:2] 1 2
.. ..- attr(*, "names")= chr [1:2] "MALE" "FEMALE"
$ gktrace : dbl+lbl [1:6325] 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1,...
..@ label : chr "TEACHER RACE/ETHNICITY KINDERGARTEN"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:6] 1 2 3 4 5 6
.. ..- attr(*, "names")= chr [1:6] "WHITE" "BLACK" "ASIAN" "HISPANIC" ...
$ gkthighdegree: dbl+lbl [1:6325] 2, 2, 3, 2, 3, 2, 3, 3, 3, 3, 2, 2, 3, 2, 2, 2, 2, 2, 2, 3,...
..@ label : chr "TEACHER HIGHEST DEGREE KINDERGARTEN"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:6] 1 2 3 4 5 6
.. ..- attr(*, "names")= chr [1:6] "ASSOCIATES" "BACHELORS" "MASTERS" "MASTERS +" ...
$ gktcareer : dbl+lbl [1:6325] 4, 4, 4, 4, 4, NA, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,...
..@ label : chr "TEACHER CAREER LADDER LEVEL KINDERGARTEN"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:7] 1 2 3 4 5 6 7
.. ..- attr(*, "names")= chr [1:7] "CHOSE NO TO BE ON CAREER LADDER" "APPRENTICE" "PROBATION" "LADDER LEVEL 1" ...
$ gktyears : num [1:6325] 5 7 8 3 12 2 7 14 4 6 ...
..- attr(*, "label")= chr "YEARS OF TOTAL TEACHING EXPERIENCE KINDERGARTEN"
..- attr(*, "format.stata")= chr "%10.0g"
$ gkclasssize : num [1:6325] 24 22 17 17 24 24 13 24 14 23 ...
..- attr(*, "label")= chr "CLASS SIZE KINDERGARTEN"
..- attr(*, "format.stata")= chr "%10.0g"
$ gkfreelunch : dbl+lbl [1:6325] 2, 2, 2, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 2...
..@ label : chr "FREE/REDUCED LUNCH STATUS KINDERGARTEN"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:2] 1 2
.. ..- attr(*, "names")= chr [1:2] "FREE LUNCH" "NON-FREE LUNCH"
$ gkrepeat : dbl+lbl [1:6325] 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
..@ label : chr "REPEATING KINDERGARTEN IN 1985-1986 SCHOOL YEAR"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:2] 1 2
.. ..- attr(*, "names")= chr [1:2] "YES, PROMOTION RECOMMENDED" "NO, PROMOTION NOT RECOMMENDED"
$ gkspeced : dbl+lbl [1:6325] 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2...
..@ label : chr "SPECIAL EDUCATION STATUS KINDERGARTEN"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:2] 1 2
.. ..- attr(*, "names")= chr [1:2] "YES" "NO"
$ gkspecin : dbl+lbl [1:6325] 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2...
..@ label : chr "PULLED OUT FOR SPECIAL INSTRUCTION KINDERGARTEN"
..@ format.stata: chr "%10.0g"
..@ labels : Named num [1:2] 1 2
.. ..- attr(*, "names")= chr [1:2] "YES" "NO"
$ gkpresent : num [1:6325] 161 175 132 178 170 94 160 154 172 95 ...
..- attr(*, "label")= chr "DAYS PRESENT AT SCHOOL KINDERGARTEN"
..- attr(*, "format.stata")= chr "%10.0g"
$ gkabsent : num [1:6325] 19 5 28 2 10 3 2 7 8 2 ...
..- attr(*, "label")= chr "DAYS ABSENT FROM SCHOOL KINDERGARTEN"
..- attr(*, "format.stata")= chr "%10.0g"
$ gktreadss : num [1:6325] NA 427 450 483 456 411 443 448 463 472 ...
..- attr(*, "label")= chr "TOTAL READING SCALE SCORE SAT KINDERGARTEN"
..- attr(*, "format.stata")= chr "%10.0g"
$ gktmathss : num [1:6325] NA 478 494 513 513 468 473 449 520 536 ...
..- attr(*, "label")= chr "TOTAL MATH SCALE SCORE SAT KINDERGARTEN"
..- attr(*, "format.stata")= chr "%10.0g"
$ gktlistss : num [1:6325] NA 509 549 554 520 571 595 540 565 595 ...
..- attr(*, "label")= chr "TOTAL LISTENING SCALE SCORE SAT KINDERGARTEN"
..- attr(*, "format.stata")= chr "%10.0g"
$ gkwordskillss: num [1:6325] NA 418 444 431 468 396 444 444 480 486 ...
..- attr(*, "label")= chr "WORD STUDY SKILLS SCALE SCORE SAT KINDERGARTEN"
..- attr(*, "format.stata")= chr "%10.0g"
$ gkmotivraw : num [1:6325] 23 24 28 27 25 24 NA NA 26 27 ...
..- attr(*, "label")= chr "MOTIVATION RAW SCORE SCAMIN KINDERGARTEN"
..- attr(*, "format.stata")= chr "%10.0g"
$ gkselfconcraw: num [1:6325] 52 53 56 61 54 55 NA NA 52 61 ...
..- attr(*, "label")= chr "SELF-CONCEPT RAW SCORE SCAMIN KINDERGARTEN"
..- attr(*, "format.stata")= chr "%10.0g"
#time to clean up these names to be easier to work with & make new dataset ##math scores (gktmathss), self-concept (gkselfconcraw), classroom type (gkclasstype) and teacher highest degree (gkthighdegree), and school average math scores.
star.clean <- projectSTAR %>%
mutate(.,
schoolid = gkschid,
classid = gktchid,
math = gktmathss,
classtype = as_factor(gkclasstype),
years.exp = gktyears,
degree = as_factor(gkthighdegree),
selfconcept = gkselfconcraw
) %>%
group_by(schoolid) %>%
mutate(.,
schoolmath = mean(gktmathss, na.rm = TRUE) #average math score via school
) %>%
ungroup() %>%
select(.,
schoolid,
classid,
math,
classtype,
years.exp,
degree,
selfconcept,
schoolmath)
glimpse(star.clean)
Rows: 6,325
Columns: 8
$ schoolid <dbl> 169229, 169280, 218562, 205492, 257899, 161176, 189382, 189382, 201449, 230612, 128…
$ classid <dbl> 16922904, 16928003, 21856202, 20549204, 25789904, 16117602, 18938204, 18938203, 201…
$ math <dbl> NA, 478, 494, 513, 513, 468, 473, 449, 520, 536, 484, 626, 454, 439, 528, NA, 463, …
$ classtype <fct> REGULAR + AIDE CLASS, REGULAR + AIDE CLASS, REGULAR + AIDE CLASS, SMALL CLASS, REGU…
$ years.exp <dbl> 5, 7, 8, 3, 12, 2, 7, 14, 4, 6, 11, 16, 12, 5, 17, 10, 6, 10, 13, 9, 18, 1, 7, 13, …
$ degree <fct> BACHELORS, BACHELORS, MASTERS, BACHELORS, MASTERS, BACHELORS, MASTERS, MASTERS, MAS…
$ selfconcept <dbl> 52, 53, 56, 61, 54, 55, NA, NA, 52, 61, 55, 49, 49, 59, 50, NA, 58, 45, NA, 55, 52,…
$ schoolmath <dbl> 498.8768, 486.9811, 501.1071, 502.6133, 476.2800, 476.7821, 479.4062, 479.4062, 503…
###Run a null model. DV: gktmathss students clustered within classrooms and schools.
model.null <- lmer(math ~ (1|schoolid) + (1|classid), data = star.clean)
summary(model.null)
Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: math ~ (1 | schoolid) + (1 | classid)
Data: star.clean
REML criterion at convergence: 60607.1
Scaled residuals:
Min 1Q Median 3Q Max
-6.2037 -0.6274 -0.0630 0.5841 3.9174
Random effects:
Groups Name Variance Std.Dev.
classid (Intercept) 287.6 16.96
schoolid (Intercept) 381.9 19.54
Residual 1612.4 40.15
Number of obs: 5871, groups: classid, 325; schoolid, 79
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 486.000 2.466 77.323 197.1 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#what does degree look like? (We already know what class type looks like) but for practice. Next time run this before null model so I know what I am looking for/at.
table(star.clean$degree)
ASSOCIATES BACHELORS MASTERS MASTERS + SPECIALIST DOCTORAL
0 4119 1981 161 43 0
table(star.clean$classtype)
SMALL CLASS REGULAR CLASS REGULAR + AIDE CLASS
1900 2194 2231
#Run ICC for class id
ICC.class <- 287.6/(287.6 + 381.9 +1612.4)
ICC.class
[1] 0.1260353
#Run ICC for schoolid
ICC.school <- 381.9/(287.6 + 381.9 + 1612.4)
ICC.school
[1] 0.1673605
#Now, run a conditional random intercept model with math scores (math) as the DV, and self-concept (selfconcept) as a student-level IV.
model.1 <- lmer(math ~ selfconcept + (1| schoolid) + (1|classid), data = star.clean)
summary(model.1)
Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: math ~ selfconcept + (1 | schoolid) + (1 | classid)
Data: star.clean
REML criterion at convergence: 48958.4
Scaled residuals:
Min 1Q Median 3Q Max
-3.8495 -0.6475 -0.0641 0.5928 3.9066
Random effects:
Groups Name Variance Std.Dev.
classid (Intercept) 283.8 16.85
schoolid (Intercept) 402.7 20.07
Residual 1551.4 39.39
Number of obs: 4756, groups: classid, 301; schoolid, 73
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 461.8411 7.1505 2370.9421 64.589 < 2e-16 ***
selfconcept 0.4522 0.1188 4687.5612 3.806 0.000143 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr)
selfconcept -0.930
##Now, run a conditional random intercept model with math scores (math) as the DV, and self-concept (selfconcept) as a student-level IV, classroom type (classtype) and teacher highest degree (degree) as teacher-level IVs.
model.2 <- lmer(math~selfconcept + classtype + degree + (1|classid) + (1|schoolid), REML=FALSE, data=star.clean)
summary(model.2)
model.3 <- lmer(math~selfconcept + classtype + degree + schoolmath + (1|classid) + (1|schoolid), REML=FALSE, data=star.clean)
boundary (singular) fit: see ?isSingular
summary(model.3)
Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: math ~ selfconcept + classtype + degree + schoolmath + (1 | classid) + (1 | schoolid)
Data: star.clean
AIC BIC logLik deviance df.resid
48768.2 48839.3 -24373.1 48746.2 4745
Scaled residuals:
Min 1Q Median 3Q Max
-3.7976 -0.6435 -0.0603 0.5904 4.0060
Random effects:
Groups Name Variance Std.Dev.
classid (Intercept) 174.4 13.21
schoolid (Intercept) 0.0 0.00
Residual 1552.8 39.41
Number of obs: 4756, groups: classid, 301; schoolid, 73
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) -14.15268 22.09078 317.69097 -0.641 0.522205
selfconcept 0.43544 0.11725 4755.84428 3.714 0.000206 ***
classtypeREGULAR CLASS -8.20633 2.35152 293.16090 -3.490 0.000558 ***
classtypeREGULAR + AIDE CLASS -8.69961 2.35099 288.49370 -3.700 0.000258 ***
degreeMASTERS -0.33621 2.10936 280.44980 -0.159 0.873477
degreeMASTERS + -2.37697 5.96377 275.53135 -0.399 0.690520
degreeSPECIALIST 19.25123 10.64910 405.76184 1.808 0.071381 .
schoolmath 0.99386 0.04374 275.01862 22.724 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) slfcnc cREGUC cRE+AC dMASTE dMAST+ dSPECI
selfconcept -0.274
cREGULARCLA -0.039 0.030
cREGULAR+AC -0.059 0.027 0.479
degrMASTERS 0.019 -0.011 -0.072 -0.064
dgrMASTERS+ 0.021 -0.007 -0.021 0.000 0.114
dSPECIALIST 0.003 -0.008 0.101 0.101 0.054 0.021
schoolmath -0.951 -0.025 -0.019 0.002 -0.043 -0.030 -0.014
convergence code: 0
boundary (singular) fit: see ?isSingular
#checking effect size for model 2 (I don’t think I need to check it here but my last model before random slopes?)
rand(model.2)
ANOVA-like table for random-effects: Single term deletions
Model:
math ~ selfconcept + classtype + degree + (1 | classid) + (1 |
schoolid)
npar logLik AIC LRT Df Pr(>Chisq)
<none> 10 -24471 48961
(1 | classid) 9 -24592 49202 242.82 1 < 2.2e-16 ***
(1 | schoolid) 9 -24521 49060 101.04 1 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#checking effect size for model 3
rand(model.3)
boundary (singular) fit: see ?isSingular
ANOVA-like table for random-effects: Single term deletions
Model:
math ~ selfconcept + classtype + degree + schoolmath + (1 | classid) +
(1 | schoolid)
npar logLik AIC LRT Df Pr(>Chisq)
<none> 11 -24373 48768
(1 | classid) 10 -24465 48949 183.04 1 <2e-16 ***
(1 | schoolid) 10 -24373 48766 0.00 1 1
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#Running random slope for self-concept (selfconcept) at the teacher/class level.
model.4 <- lmer(math~selfconcept + classtype + degree + schoolmath + (selfconcept|classid) + (1|schoolid), REML=FALSE, data=star.clean)
unable to evaluate scaled gradientModel failed to converge: degenerate Hessian with 1 negative eigenvaluesModel failed to converge with 1 negative eigenvalue: -9.6e+00
summary(model.4)
Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: math ~ selfconcept + classtype + degree + schoolmath + (selfconcept |
classid) + (1 | schoolid)
Data: star.clean
AIC BIC logLik deviance df.resid
48770.8 48854.9 -24372.4 48744.8 4743
Scaled residuals:
Min 1Q Median 3Q Max
-3.7969 -0.6429 -0.0614 0.5912 4.0142
Random effects:
Groups Name Variance Std.Dev. Corr
classid (Intercept) 3.485e+02 18.6695
selfconcept 6.847e-02 0.2617 -0.71
schoolid (Intercept) 9.128e-02 0.3021
Residual 1.551e+03 39.3882
Number of obs: 4756, groups: classid, 301; schoolid, 73
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) -14.4199 22.0405 318.1812 -0.654 0.513427
selfconcept 0.4388 0.1187 2037.8827 3.697 0.000224 ***
classtypeREGULAR CLASS -8.1850 2.3432 296.0238 -3.493 0.000551 ***
classtypeREGULAR + AIDE CLASS -8.6691 2.3425 291.1453 -3.701 0.000257 ***
degreeMASTERS -0.3135 2.1019 282.3378 -0.149 0.881551
degreeMASTERS + -2.2290 5.9444 277.3880 -0.375 0.707968
degreeSPECIALIST 19.3272 10.6314 396.6436 1.818 0.069828 .
schoolmath 0.9940 0.0436 273.2880 22.796 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) slfcnc cREGUC cRE+AC dMASTE dMAST+ dSPECI
selfconcept -0.277
cREGULARCLA -0.040 0.032
cREGULAR+AC -0.060 0.028 0.480
degrMASTERS 0.019 -0.011 -0.072 -0.064
dgrMASTERS+ 0.021 -0.006 -0.022 -0.001 0.114
dSPECIALIST 0.003 -0.008 0.101 0.101 0.053 0.021
schoolmath -0.950 -0.027 -0.019 0.002 -0.043 -0.030 -0.014
convergence code: 0
unable to evaluate scaled gradient
Model failed to converge: degenerate Hessian with 1 negative eigenvalues
#Running random slope for self-concept (selfconcept) at the school level.
model.5 <- lmer(math~selfconcept + classtype + degree + schoolmath + (1|classid) + (selfconcept|schoolid), REML=FALSE, data=star.clean)
boundary (singular) fit: see ?isSingular
summary(model.5)
Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: math ~ selfconcept + classtype + degree + schoolmath + (1 | classid) +
(selfconcept | schoolid)
Data: star.clean
AIC BIC logLik deviance df.resid
48763.3 48847.4 -24368.6 48737.3 4743
Scaled residuals:
Min 1Q Median 3Q Max
-3.7454 -0.6503 -0.0607 0.5866 4.0344
Random effects:
Groups Name Variance Std.Dev. Corr
classid (Intercept) 169.4817 13.0185
schoolid (Intercept) 1733.5612 41.6361
selfconcept 0.5549 0.7449 -1.00
Residual 1540.9570 39.2550
Number of obs: 4756, groups: classid, 301; schoolid, 73
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) -14.19106 22.49511 324.23626 -0.631 0.528582
selfconcept 0.41450 0.14949 64.96742 2.773 0.007245 **
classtypeREGULAR CLASS -8.28684 2.33591 298.05015 -3.548 0.000451 ***
classtypeREGULAR + AIDE CLASS -8.67911 2.33323 292.28934 -3.720 0.000239 ***
degreeMASTERS -0.59336 2.09262 283.66571 -0.284 0.776964
degreeMASTERS + -2.55123 5.92240 279.49950 -0.431 0.666963
degreeSPECIALIST 19.55020 10.59636 414.03966 1.845 0.065753 .
schoolmath 0.99669 0.04336 277.31610 22.988 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) slfcnc cREGUC cRE+AC dMASTE dMAST+ dSPECI
selfconcept -0.352
cREGULARCLA -0.040 0.027
cREGULAR+AC -0.058 0.023 0.481
degrMASTERS 0.019 -0.011 -0.072 -0.064
dgrMASTERS+ 0.020 -0.005 -0.021 -0.001 0.114
dSPECIALIST 0.004 -0.010 0.100 0.101 0.052 0.021
schoolmath -0.925 -0.023 -0.019 0.002 -0.043 -0.029 -0.014
convergence code: 0
boundary (singular) fit: see ?isSingular
#checking to see if random slopes was fruitful
anova(model.3,model.4)
Data: star.clean
Models:
model.3: math ~ selfconcept + classtype + degree + schoolmath + (1 | classid) +
model.3: (1 | schoolid)
model.4: math ~ selfconcept + classtype + degree + schoolmath + (selfconcept |
model.4: classid) + (1 | schoolid)
npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
model.3 11 48768 48839 -24373 48746
model.4 13 48771 48855 -24372 48745 1.353 2 0.5084
#checking to see if rand slopes was good for second slope.
anova(model.3, model.5)
Data: star.clean
Models:
model.3: math ~ selfconcept + classtype + degree + schoolmath + (1 | classid) +
model.3: (1 | schoolid)
model.5: math ~ selfconcept + classtype + degree + schoolmath + (1 | classid) +
model.5: (selfconcept | schoolid)
npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
model.3 11 48768 48839 -24373 48746
model.5 13 48763 48847 -24369 48737 8.8782 2 0.01181 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1