3
$\begingroup$

I'm doing a mixed linear model. And I have subjects who have been select in 20 schools. So I want to take this to account.

For this, I want to put a random intercept for the "SCHOOL" variable and a random intercept and slope for my "SUBJECT". But I want to take into account the nested effect.

Does this code fit the nested model:

 lme(Y ~ T + X, random = list(SCHOOL = ~ 1, SUBJECT = ~ T), method = "ML")

T is the time, and Y the outcome.

$\endgroup$
3
$\begingroup$

This code specifies that SUBJECT is nested within SCHOOL, and that for SCHOOL you have random intercepts, and for SUBJECT random intercepts and random slopes.

You could also fit the model with restricted maximum likelihood that provides better estimates for the variance components in small samples.

$\endgroup$
  • $\begingroup$ Thanks for your answer. I assume it's correct so. Small samples correspond to an effective of less of 100 ? My sample is constituate of about 600 subjects ... $\endgroup$ – Klmce Apr 11 at 19:24
0
$\begingroup$

I'm not sure how to do it in package NLME, but with LME4 you could do it with:

lmer(y ~ t + x + (1 + T|SUBJECT:SCHOOL), REML = FALSE)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.