Parameter Declaration in brms

  • Operating System: Windows 10
  • brms Version:


I am currently trying to fit a multilevel non-linear model, which uses paired, repeated measures data (data of patients before and after a medical procedure, in each case several measurements per patient are taken).
I read some of the docs provided on brms, but still have some doubts as to whether I am getting the parameter declaration right.
I am fitting the following model:
fit<- brm(
bf(LDL ~ 15 + (alpha-15) / (1 + exp ((gamma-Time) / delta)),
alpha ~ 1 + (1|Sample)+(1|Cat),
gamma ~ 1 + (1|Sample)+(1|Cat),
delta ~ 1 + (1|Sample)+(1|Cat),
nl = TRUE),

data = ldlData, family = gaussian(),
chains = 2,
warmup = 1000,
cores = getOption(“mc.cores”,1L),
control = list(adapt_delta = 0.999)

As seen from the code, the parameters are alpha, gamma, and delta.
Let us take alpha, for example:

alpha ~ 1 + (1|Sample)+(1|Cat) (1)

In this case, does this mean that alpha has a fixed effect, represented by the first 1 in the expression and two independent group effects (alpha varies per Sample and per Category - Before/After procedure).
In addition, if I want to write a model, in which Sample is influenced by Category,
I think I should use
alpha ~ 1 + (1|Cat/Sample) = 1 + (1|Cat) + (1|Cat:Sample) (2)

In case two is correct, can someone confirm what exactly the intuition behind it is -
the way I see it, it says that Cat contributes to a group effect for the whole population, and also influences the group effect per Sample in a specific Category.
Is this correct?



Welcome to the discourse 👋!

I usually see this syntax described as a way to handle nesting. This syntax says that the intercept should vary by Cat and by Sample levels which are nested inside of Cat levels. This cheatsheet, geared for the lme4 package, for example, uses Therapist/Patient to model repeated measures from Patients nested in Therapists.




Thanks for your reply. The link you provided is particularly useful!
Unfortunately, when I change the definitions of the parameters to

 alpha ~ 1 + (alpha|Cat/Sample),
 gamma ~ 1 + (gamma|Cat/Sample),
 delta ~ 1 + (delta|Cat/Sample),

I get an error :
Error: The following variables are missing in ‘data’:
‘alpha’, ‘gamma’, ‘delta’.

It seems like the program reads my parameters as variables in my data.
I saw a post describing this problem somewhere, which suggested to read the documentation, I did, but for some reason didn’t find the answer.
Any idea how this can be fixed?