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…
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),
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?