R: lm and lmer produce the same results

Viewed 128

I recently conducted a study in which I divided participants into two conditions. They rated different items. I wanted to test whether their ratings differed between the two conditions. Because these items differed substantially and I was taking many measurements per participant, I decided to add at least random intercepts for items (coded as "item") and participants (coded as "id").

I fit the following model with the lme4 package:
lmer(y ~ condition + (1|id) + (1|item), dfLong)

But, then I fit the following simple linear model to the index measure created by averaging all responses for each participant:
lm(itemMean ~ condition, dfWide)

And the results were exactly the same as those I got with LMM! If I remove the random intercept for items, i.e. (1|Item), then the results remain unchanged! Does anyone know why a linear model fitted to the aggregate (averaged response) data gives the same standard errors as LMM with random intercepts for items and participants?

Below I attach the mwe in R.

dfWide <- data.frame(
  condition=c('a','a','b'),
  item1=c(55,30,65),
  item2=c(35,30,45),
  item3=c(45,30,40),
  itemMean=c(45,30,50)
)

dfLong <- data.frame(
  id=c(1,1,1,2,2,2,3,3,3),
  condition=c('a','a','a','a','a','a','b','b','b'),
  item=c('item1','item2','item3','item1','item2','item3','item1','item2','item3'),
  y=c(55,35,45,30,30,30,65,45,40)
)

summary(lmer(y ~ condition + (1|id) + (1|item), dfLong))
summary(lm(itemMean ~ condition, dfWide))

PS: removing random intercept for participants (1|id) produces results that I expected, with lower standard errors. Is there anything wrong with the random effects structure I use in this particular study?

0 Answers
Related