# Predicting Random Slopes

#### Lazar

##### Phineas Packard
I have a model as follows:

Level 1 (students): Variables = educational aspirations (expect) and socioeconomic status (ses)
Level 2 (schools): not interested in this level just controlling for it
Level 3 (countries): Variables = educational equity (ICC)

the models is:
glmer(expect~ses+(1|schools)+(ses|countries), data=PISA, family=binomial)

Thus the effect of ses on expect is random at the country level. What I want to be able to do is see whether ICC (educational equity) explains a significant amount of the variance in the random ses parameter. In other words I want to know whether ses predicts educational expectations to a greater extent in countries with less educational equity.

I know how to do this in mplus but how would I do this in lme4?

#### Lazar

##### Phineas Packard
I should be a little more specific. Essentially I need to know how to included level 3 ICC into:

Code:
glmer(expect~ses+(1|schools)+(ses|countries), data=PISA, family=binomial)#where does ICC go?
such that I can see the degree to which ICC predicts the variance in the SES~expect slope at the country level.

#### Jake

##### Cookie Scientist
You can simply use
Code:
glmer(expect~ses+ICC+(1|schools)+(ses|countries), data=PISA, family=binomial)
Since ICC does not vary within the levels of any of your random factors (each student, school, and country is associated with one and only one value of ICC), the ICC term only goes in the fixed part of the model. We cannot estimate random ICC slopes.

#### Lazar

##### Phineas Packard
Hi Jake,

Yes I know it cannot be random but will the above give me an indication of the degree ICC explains the variaiance in the random slope (ses|countries). My guess is I could run one model with ICC in and one without and then compare the variance in the random slope between the two models. Does that make sense?

~Lazar

#### Jake

##### Cookie Scientist
Ah I see. So I believe you are just talking about an ses*ICC interaction, right? So you fit a model with that interaction and then one without (i.e., the model I wrote above), and compare the variance in the random ses slopes between those two models. The amount by which the variance in the random ses slopes by country decreases when moving from the additive model to the interactive model is the amount that was attributable to country differences in ICC. And as for a significance test, it is just testing the significance of the fixed interaction term.

#### Lazar

##### Phineas Packard
Thank you yes this is my logic and now I feel safer having you confirm it.