Solved – Random effects for within subjects study in R

rrandom-effects-modelrepeated measures

I have data which consists of subjective ratings. The ratings are done by different judges with each subject being judged under different experimental conditions. Each subject undergoes each condition and every judge (i.e. for two judges and three conditions there are six ratings per subject).

I am interested in the effect of the specific conditions, but not the effect of the specific judges whom I consider as drawn from a large population of possible judges. That makes the condition a fixed factor and the judges a random factor.

1) I believe that both the condition and the judge are within-subjects factors because each subject is exposed to each combination of condition and judge. However, I am unsure because the same judges and same conditions are used for all subjects.

2) Which R function is best for this kind of data, and how would I specify the model? For example, I tried ezANOVA, but could not find how to specify the judges as a random factor.

Best Answer

I would go for package lme4.

If I understand correctly, mF below should be your model. It has condition as a fixed effect, while judge and subject as a random intercepts.

library(lme4)

# m0 = Null model without the fixed effects.
# m1 = Your model including the fixed effects.
# Set REML = FALSE for a meaningful model comparison

m0 <- lmer(rating ~ 1 + (1|judge) + (1|subject), data = data, REML = FALSE) 
mF <- lmer(rating ~ condition + (1|judge) + (1|subject), data = data, REML = FALSE) 

summary(m0)
summary(mF)

anova(m0, mF)

# If significant, fit the final model using REML = TRUE
# This is often recommended since it usually gives better estimates for random effects.

mF <- lmer(rating ~ condition + (1|judge) + (1|subject), data = data, REML = FALSE)

Edit: Per discussion below.

Related Question