My assignments will need to be completed with HLM but I want to learn how the models work in R's lme4 syntax as well.

This weeks lab had us run 3 models: fully unconditional, partially conditional and fully conditional. Here is the HLM output for each:

**fully unconditional**

http://htmlpreview.github.io/?https://github.com/trinker/HLM2R/blob/master/fully unconditional.html

**partially conditional**

http://htmlpreview.github.io/?https.../HLM2R/blob/master/partially conditional.html

**fully conditional**

http://htmlpreview.github.io/?https://github.com/trinker/HLM2R/blob/master/fully conditional.html

I have tried to replicate this with the following R script (this will load the data and group center the SES variable):

**Code Book**

minority: indicator of student minority race/ethnicity; 1 = minority, 0 = not minority

female: indicator of student gender; 1 = female, 0 = male

ses: standardized composite representing socioeconomic status; constructed from

variables measuring parent education, income, and occupation

mathach: mathematics achievement test score

size: total school enrollment

sector: type of school; 1 = Catholic, 0 = public

pracad: proportion of students on the academic track

disclim: a scale measuring disciplinary climate

himinty: level of minority enrollment; 1 ≥ 40%, 0 = < 40%

meanses: mean SES value for the students who are in the level-1 file and attend this school

Code:

```
## Load data and lme4
load(url("http://dl.dropboxusercontent.com/u/61803503/data/HSB.RData"))
head(dat)
library(lme4)
## Group Center Variables
dat$cent_ses <- with(dat, ses - ave(ses, id))
## Fully Unconditional
fu_mod <- lmer(mathach ~ 1 + (1 | id), data=dat)
summary(fu_mod)
## Partially Conditional
pc_mod <- lmer(mathach ~ cent_ses + (1 | id), data=dat)
summary(pc_mod)
## Fully Conditional
fc_mod <- lmer(mathach ~ cent_ses + (1 | id) + (1 | meanses) +(id | sector), data=dat)
summary(fc_mod)
```

**Questions:**

- I think I have replicated the fully unconditional and partially unconditional models correctly. How can I specify the fully conditional model in R that matches the HLM otput?
- How can I get the reliabilities from lme4?
- They use a Chi Squared test and log liklihood to look at final variance effect. How can I get lme4 to get this output?

For the Fully Conditional Model

Code:

```
Random Effect Stan.Deviation Variance d.f. χ2 p-value
INTRCPT1, u0 1.54271 2.37996 157 605.29503 <0.001
SES slope, u1 0.38590 0.14892 157 162.30867 0.369
level-1, r 6.05831 36.70313
```

**anova**function but am unsure of which models to compare to which. I think maybe it's compared to the previous but am unsure and

**anova(fu_mod, pc_mod)**doesn't give me the table from http://htmlpreview.github.io/?https.../HLM2R/blob/master/partially conditional.html

Thank you in advance.

My TA sent me the lab (not graded) so I could compare: http://htmlpreview.github.io/?https...r/HLM,lab1,output, including all 3 models.htm