5
$\begingroup$

Suppose we have 500 students nested in 20 classes (different classrooms), 25 students per class

student<-factor(1:500)
class<-rep(LETTERS[1:20],each=25)

They all take a test.

score<-rnorm(500,mean=80,sd=5)

The model below would tell you about the average scores and variability among students and classes

library(lme4)
lmer(score~(1|class))

Suppose further that a random 10 of the classrooms were painted red the other 10 were painted blue.

redvblue<-rep(0:1,each=250)

Is this a reasonable way to test for the effect of redvblue on test scores? And if it is reasonable, is there a better way?

lmer(score~redvblue+(1|class))

I'm wondering whether I should be concerned that redvblue was applied at the classroom level rather than the student level.

$\endgroup$
2
$\begingroup$

Your approach is fine and appropriate. The power of mixed effects models is that they can be used to analyze data like yours or where treatments were at the individual level, or both.

$\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.