- Operating System: Windows 10
- brms Version: 2.8

I am fitting a nonlinear mixed-effects model to longitudinal data.

Here are some useful details about the dataset:

Data has been obtained from N patients before and after an operation.

For each patient, M measurements of the dependent variable have been obtained both before and after the operation.

I am modelling my data using a slightly modified Richard’s curve, the formula given as:

LDL ~ 15 + (alpha - 15) / (1 + exp ((gamma - Time) / delta))

where *LDL* is my dependent variable, *Time* is an independent variable, and *alpha, gamma, delta* - parameters to be estimated.

What I would like to do is include a variable *Category* - with “Before” and “After” values, which would denote whether a measurement from a patient has been taken before or after the operation. I think *Category* should be a fixed effect, as I believe that there is some consistency in the measurements that have been taken before/after the operation. I would like to declare *Category* as be a fixed effect, however, I am not quite sure how to declare it in my model. Am I supposed to add it somewhere in the formula given above, or how exactly would it work?

I did go through some examples of declaration of mixed effects models, but nowhere did I find something which answers my question - the examples were either for linear models or all of the fixed effects were included in the formula for the model, which is not my case.

I provide some of my code below:

fit_model ← function(Data){

fit<- brm(

bf(LDL ~ 15 + (alpha - 15) / (1 + exp ((gamma - Time) / delta)),

alpha ~ 1 + (1|Sample) ,

gamma ~ 1 + (1|Sample),

delta ~ 1,

nl = TRUE),

prior = c(

prior(normal(1500, 30), class=“b”,nlpar = “alpha”),

prior(normal(2.5,0.07), class=“b”, nlpar = “gamma”),

prior(normal(0.2,0.05), class=“b”, lb=0, ub=0.5, nlpar = “delta”),

prior(student_t(3, 0, 10), class=“sigma”),

prior(student_t(3, 0, 10), class=“sd”, nlpar=“alpha”),

prior(student_t(3, 0, 10), class=“sd”, nlpar=“gamma”),

prior(normal(0.4,0.03 ), class=“sd”, group=“Sample”, coef=“Intercept”, nlpar=“gamma”),

prior(normal(300,10), class=“sd”, group=“Sample”, coef=“Intercept”, nlpar=“alpha”)),

data = Data, family = gaussian(),

I would really appreciate it if someone could give me some insight.