Skip to content
Prev 10139 / 20628 Next

Design Matrix for Random effects

Hi Robert,

A further problem could be that R is somewhat reluctant to fit models with interactions but without main effects.
I asked this on SO quite some time ago (with nice answers from regulars on this list, Ben Bolker and Joshua Wiley): http://stackoverflow.com/q/11335923/289572

Even if you specify to exclude the main effects in presence of interaction, their parameters will be there. In your data:

require(lme4)
cutsim <- read.csv(file="cutsim.csv", header=T)
cutsim$Species <- as.factor(cutsim$Species)
cutsim$Farm <- as.factor(cutsim$Farm)

# model without main effect:
model2 <- lmer(Yield ~ Species + Species:Farm + (1|Animal), data=cutsim, doFit = FALSE, REML=TRUE)
length(model2$fr$fixef)
# 500 fixed effects parameters

# model with main effect
model3 <- lmer(Yield ~ Species*Farm + (1|Animal), data=cutsim, doFit = FALSE, REML=TRUE)
length(model3$fr$fixef)
# 500 fixed effects parameters

Cheers,
Henrik


Am 28/05/2013 19:55, schrieb W Robert Long: