Question

This is a question about lme() syntax. My response variable is 'response'. My fixed variable is 'year'. I have 2 random variables: 'student' which is nested within 'school'.

I want to include a year*school interaction, but I do NOT want to include a year*student one.

This is the syntax I have so far, but this seems to include 2 random interactions where I only want 1.

lme1 = lme(response ~ 1 + year, random = ~ year | school/student, 
            method = "REML", data = data)
Was it helpful?

Solution

This would be much easier to do in lmer from the lme4 package. Assuming each student has a unique identifier, it would look like this (untested).

lmer(response ~ year + (year | school) + (1 | student), data = data)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top