0
votes

I'm attempting to "translate" a model run in HLM7 software to R lmer syntax.

This is from the now-ubiquitous "Math achievement" dataset. The outcome is math achievement score, and in the dataset there are various student-level predictors (such as minority status, SES, and whether or not the student is female) and various school level predictors (such as Catholic vs. Public).

The only predictors in the model I want to fit are student-level predictors, which have all been group-mean centered to deal with dummy variables (aside: contrast codes are better). The students are nested in schools, so we should (I think) have random effects specified for all of the components of the model.

Here is the HLM model:

Level-1 Model (note: all predictors at level one are group mean centered) MATHACHij = β0j + β1j*(MINORITYij) + β2j*(FEMALEij) + β3j*(SESij) + rij

Level-2 Models

β0j = γ00 + u0j

β1j = γ10 + u1j

β2j = γ20 + u2j

β3j = γ30 + u3j

Mixed Model

MATHACHij = γ00 + γ10*MINORITYij + γ20*FEMALEij + γ30*SESij + u0j + u1j*MINORITYij + u2j*FEMALEij + u3j*SESij + rij

Translating it to lmer syntax, I try: (note: _gmc means the variable has been group mean centered, the grouping factor is "school_id")

model1<-lmer(mathach~minority_gmc+female_gmc+ses_gmc+(minority_gmc|school_id)+(female_gmc|school_id)+(ses_gmc|school_id), data=data, REML=F)

When I run this model I get results that don't mesh with the HLM results. Am I specifying the random effects incorrectly?

Thanks!

1
you may need some 0+ terms in your random effects to suppress the intercepts?Ben Bolker
u0j - Is this a random intercept by school? In lmer, that would be (1 | school_id).Neal Fultz
Yes, u0j is a random intercept by school. So I'll try to add the (1|school_id) and also suppress the intercepts in the other random effects (was thinking I might need to do that).Kate Phelps

1 Answers

0
votes

When you specify your random effect structure, you can include each random effect in one parentheses. While this may not solve your result dependencies, I believe the appropriate random effects code syntax for your model is this:

lmer(mathach~minority_gmc + female_gmc + ses_gmc + (1 + minority_gmc + female_gmc + ses_gmc |school_id), data=data, REML=F)