[R-sig-ME] [R] Meaning of /, :, and %in% in lmer

Douglas Bates bates at stat.wisc.edu
Fri Apr 18 14:11:57 CEST 2008

On 4/16/08, Claus Wilke <cwilke at mail.utexas.edu> wrote:
> Hello,

>  I asked this question a little while ago (
>  https://stat.ethz.ch/pipermail/r-help/2008-April/158761.html ) but got no
>  response. Can anybody explain to me the difference between /, :, and %in% in
>  the definition of random effects in lmer, such as:
>  (1|A/B), (1|A:B), (1|B %in% A)?

The first two, (1|A/B) and (1|A:B), are forms that lmer recognizes.
I'm not sure what the effect of the third form, (1|B %in% A), would be
and would not advise using it.

Most uses of the %in% operator in R at present are as a logical operator.

>  My understanding is that (1|A/B) is the same as (1|A) + (1|A:B), but I have
>  not seen this stated explicitly anywhere. And I don't understand why (1|A/B)
>  seems to be different from (1|A) + (1|B %in% A), isn't that what %in% means?

The short answer is that (1|A/B) is expanded to (1|A) + (1|A:B) so you
can choose whatever form makes sense to you.

There are different circumstances where a notation like (1|A/B) would
be used.  Some are reasonable choices and some are artifacts of
artificial ways of assigning labels to factor levels.  Rather than my
trying to guess what kind of application you have in mind, could you
describe a situation where you would want to fit an lmer model with
terms like that?

I am cc:ing the R-SIG-Mixed-Models list on this reply and I suggest we
move the discussion to that list.

More information about the R-sig-mixed-models mailing list