Modelling more complex ranef structure

Hi all,

I am new to Stan and brms but do have experience in lme4, mgcv etc. and “classical” R packages. With lmer() model one can do this:

lmer(RT ~
    TrialOrder +
    ... +
    (1|Item) +
    (1|Participant) +
    (0+TrialOrder|Participant)
    ...

With mgcv one can specify similar ranef structure.
How can this be achieved with brms? Using ... + lf(sigma ~ 0 + TrialOrder) + ... is not exactly the same .

Many thanks!

Hi there! Welcome to the Stan forum! :)

Did you try using the lme4 syntax in brms? I think it should work.

Cheers,
Max

1 Like

And it did! Thanks! I have found the bug in my code as I (wrongly) did this:

... +
(1|RECORDING_SESSION_LABEL) +
(1+TRIAL_INDEX.z|RECORDING_SESSION_LABEL),
...

While I actually wanted this:

... +
(1|RECORDING_SESSION_LABEL) +
(0+TRIAL_INDEX.z|RECORDING_SESSION_LABEL),
...

So, Duplicated group-level effects are not allowed

But I still cannot wrap my head around some details in how and what you can do with ranefs. Could you recommend something to help me grasp what these two puppies are doing (I am making generic examples here):
[1]

lf(sigma ~ 0 + X1)

[2]

(1|RECORDING_SESSION_LABEL)

vs.

(1|p|RECORDING_SESSION_LABEL)

Thanks!

1 Like

Hey! Glad it worked! :)

I’m not quite sure, but I think the only difference of (1|RECORDING_SESSION_LABEL) vs. (1|p|RECORDING_SESSION_LABEL) is that the latter allows the random effects to be correlated across regression functions (when you are modelling multi-outcome regressions). The correlation (matrix) is captured by p or whatever name you put there.

Cheers,
Max

edit: I you consider one of my answers as solution to your question please mark it as solution. This helps us see which threads needs attention and it helps that look for solutions. Thanks! :)

1 Like