Clarification on the meaning of || in brms syntax

Please also provide the following information in addition to your question:

  • Operating System: Windows 10
  • brms Version:

I am currently trying to fit a multilevel model and am having some troubles with understanding the exact use of || in brms syntax.
I read the vignettes but am somehow still confused about it.

1. Here I read the following:

The / operator indicates nested grouping structures and expands one grouping
factor into two or more when using multiple / within one term. If, for instance, you write (1 | g1/g2),
it will be expanded to (1 | g1) + (1 | g1:g2). Instead of | you may use || in grouping terms to prevent group-level correlations from being modeled.

So, for example, if we have

A ~ 1 + (1|g1/g2)

This would mean that A has a fixed effect + two random effects, 1|g1 and 1|g1:g2, and these two random effects of A can potentially be correlated,
but if we use

A ~ 1 + (1||g1/g2)

this would mean that 1|g1 and 1|g1:g2 random effects for A will NOT be correlated.
Is this a correct way to interpret it?

2. Here it says

Group-level terms are of the form (coefs | group), where coefs
contains one or more variables whose effects are assumed to vary with the levels of the grouping factor given in group. Multiple grouping factors each with multiple group-level coefficients are possible…
By default,
group-level coefficients within a grouping factor are assumed to be correlated. Correlations can be set to zero by using the (coefs || group).

So, for example, if we have two variables

A ~ 1+ (1|g1)
G ~ 1+ (1|g1)

this would mean that the group effect A|g1 is potentially correlated with G|g1, but if we write

A ~ 1+ (1||g1)
G ~ 1+ (1||g1)

this would mean that the random effect A|g1 is NOT correlated with G|g1?

I think my confusion comes from the fact that || seems to mean
no correlation between two different group effects on the same variable in (1),
and
no correlation between the same group effect of the same grouping factor on two different variables.

Now, if we make it even more complicated, if we have

A ~ 1+ (1||g1+g2)
G ~ 1+ (1||g1+g2)

This would mean that A|g1 is NOT correlated with A|g2, but also
A|g1+g2 is NOT correlated with G|g1+g2?
Is this correct?

1 Like

You are largely correct, but let me add one thing: Two varying effects of different grouping variables (g1 and g2, say) will never be modeled as correlated, as there is (unless we are in specific situation) nothing to be correlated since g1 and g2 have different levels.

That way || just removes the correlations from varying effects on the same grouping variable.

Hi, Paul, thank you for the clear answer!
I would like to ask one more thing - if we have a choice of whether the group-level coefficients within a grouping factor would be correlated or not, why would we ever choose for them to be correlated? This is, why does the | exist, if we could always use || instead to make sure they are not correlated?

Doesn’t lack of correlation between group-level coefficients within a grouping factor make the model somewhat simpler? And, if so, why would we ever choose to use the | in a model then? Are there any advantages for this?

I would argue it’s actually the other way round. Why would I not want to estimate correlations? Group-level effects may be correlated anyway even if the model assumes they are not. But by explicitely modeling the correlation I allow the group-level effects to inform each other thus improving precision for all of them.

Making the model simpler is only reasonable if this simplicity is justified and usually (in this case) it is not. Instead, fixing the correlations to zero is, in my opinion, mostly an unnecessary restriction of the model to we should avoid if possible.

3 Likes

I see! That makes sense, thanks!

Hi Paul,
You so I have understood correctly. If I would have had a dataset from student in different schools, you would have preferred to use e.g. (1 + factor | students/school) rather than (1 + factor | students) + (1 + factor | school) or (1 + factor | | students/school)?

I only talked about (.|.) vs. (.||.). The two (.|.) you mentioned are equivalent to each other if students have a unigue ID across schools. See also the brms_multilevel vignette.

1 Like