Import Snijders data and replicate Mplus model results reported at UCLA

library(lme4)
library(QuantPsyc)
colnames = c("schoolnr", "pupilnr", "iq_verb", "iq_perf", "sex", "minority", 
    "repeatgr", "aritpret", "classnr", "aritpost", "langpret", "langpost", "ses", 
    "denomina", "schoolse", "satiprin", "natitest", "meetings", "currmeet", 
    "mixedgra", "percmino", "aritdiff", "homework", "classsiz", "groupsiz")
m1 = read.csv(file = "~/Dropbox/perdevarbeit/Jaap/snijders beispieldaten/mlbook1.dat", 
    col.names = colnames, header = F, na.strings = "-9999")
source("~/R/self-insight/diary/2- jaap instruction - snippet calculate slope reliability.R")


(int.only = lmer(langpost ~ (1 | schoolnr), data = m1))
## Linear mixed model fit by REML 
## Formula: langpost ~ (1 | schoolnr) 
##    Data: m1 
##    AIC   BIC logLik deviance REMLdev
##  16259 16276  -8127    16253   16253
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  schoolnr (Intercept) 19.6     4.43    
##  Residual             64.6     8.04    
## Number of obs: 2287, groups: schoolnr, 131
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)   40.362      0.428    94.3

(verb = lmer(langpost ~ iq_verb + (1 | schoolnr), data = m1))
## Linear mixed model fit by REML 
## Formula: langpost ~ iq_verb + (1 | schoolnr) 
##    Data: m1 
##    AIC   BIC logLik deviance REMLdev
##  15264 15287  -7628    15252   15256
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  schoolnr (Intercept)  9.6     3.1     
##  Residual             42.2     6.5     
## Number of obs: 2287, groups: schoolnr, 131
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)  11.1698     0.8795    12.7
## iq_verb       2.4876     0.0701    35.5
## 
## Correlation of Fixed Effects:
##         (Intr)
## iq_verb -0.937

m1a = read.csv(file = "~/Dropbox/perdevarbeit/Jaap/snijders beispieldaten/mlbook1_a.dat", 
    col.names = c("schoolnr", "pupilnr", "iq_verb", "iq_perf", "sex", "minority", 
        "repeatgr", "aritpret", "classnr", "aritpost", "langpret", "langpost", 
        "ses", "denomina", "schoolses", "satiprin", "natitest", "meetings", 
        "currmeet", "mixedgra", "percmino", "aritdiff", "homework", "classsiz", 
        "groupsiz", "iq_verbc", "iqbar"), header = F, na.strings = "-9999")

(within.between = lmer(langpost ~ iq_verbc + iqbar + (1 | schoolnr), data = m1a))
## Linear mixed model fit by REML 
## Formula: langpost ~ iq_verbc + iqbar + (1 | schoolnr) 
##    Data: m1a 
##    AIC   BIC logLik deviance REMLdev
##  15242 15271  -7616    15228   15232
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  schoolnr (Intercept)  7.89    2.81    
##  Residual             42.17    6.49    
## Number of obs: 2287, groups: schoolnr, 131
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)  40.7410     0.2866   142.2
## iq_verbc      2.4148     0.0717    33.7
## iqbar         1.5892     0.3148     5.0
## 
## Correlation of Fixed Effects:
##          (Intr) iq_vrb
## iq_verbc  0.000       
## iqbar     0.077 -0.228