I want to run a random intercept mixed-effect model, with two random intercepts. I made some example data below, which consists of 10 subjects from 3 families that go to 3 different schools. They get two types of training, that I want to include as fixed effects.
Mock data:
data <- data.frame(child=rep(1:10),
school=c(2,1,1,2,3,1,2,3,2,1),
family=c(1,3,2,1,2,2,3,2,1,3),
training_1=c(5,4,6,5,6,7,8,6,5,6),
training_2=c(4,7,4,5,5,8,6,5,8,5),
score=c(46,56,60,68,70,55,67,60,59,47))
I run the following lme command with training_1 & training_2 as fixed effects, and family and school as random intercepts:
m1 <- lme(score~
training_1+
training_2,
random=list(~1|family, ~1|school),
method="ML",
data=data)
summary(m1)
If I'm not mistaken, family and school are now analyzed as "nested", which means that a certain family appears only within a particular school. In my data however, different family members from the same family can end up in different schools, which means that I should analyze them as "crossed", right? How do I adjust my lme command to do this?
~1|family/school
. $\endgroup$