lmer syntax questions

Viewed 83

I am trying to do some mixed/fixed effect modelling, and have come across the lme4 package, which includes the lmer function. But I am really confused about the syntax to be honest, and I have tried looking into the documentation, but I am not sure I fully understand, and also it seems like the ones I have differ a bit.

For example I have something like this:

T <- lmer(Y ~ Treatment + 0 + (1|Block) + (1|Subblock), data = D, REML = FALSE)
T1 <- lmer(Y ~ 1 + (1|Block) + (1|Subblock), data = D, REML = FALSE)

Can anyone "quickly" explain what this actually means ? Like, the 1's before the | means that the variable Block or Subblock should be treated as random effect, and Treatment is a fixed effect. But what about the single 1's and 0's ? Can I change the 1's before the | to 0's, and if so, what does that mean ?

1 Answers
Y ~ Treatment + 0 + (1|Block) + (1|Subblock)

(I wouldn't recommend using T as variable name in R, by the way ...)

  • 0+Treatment denotes a fixed effect of treatment, in "dummy" or "treatment" coding (the default), with the intercept suppressed (that's what the 0 denotes here); in other words, you will have one fixed-effect parameter per level of Treatment, equal to the expected value for observations in that treatment.
  • (1|Block) + (1|Subblock) denotes random variation in the intercept of the model (that's what 1 means here) among blocks and among subblocks: it assumes that subblocks are uniquely coded (e.g. A1, A2, ..., B1, B2, ... rather than 1, 2, ... , 1, 2, ...)
Y ~ 1 + (1|Block) + (1|Subblock)

Same as above, but now there is no fixed effect of treatment - only an experiment-wide intercept value.

You would compare these two models (e.g. with anova() to do a likelihood ratio test or AIC()) to test the statistical significance of Treatment.

See the GLMM FAQ or this question for more details on lme4 syntax.

PS changing 1 to 0 in the random effects specification would be weird; if it worked at all (which I'm not sure it would), it would in principle be equivalent to suppressing that random effect ("what varies across groups? nothing") - which would be easier to do by just leaving that RE out of the formula altogether ...

Related