I am trying to run some additive models using brms.

Some context:

I am trying to model some infant pupillometry data (for info you can even see my previous post: Additive model with random smooth for participant). I have run all my models with MGCV with success and now I am trying to move to brms.

I successfully run my main model that tests for

- Interaction between Event (variable of interest; factorial with 2 levels) and Trial number
- Smooth term on time (ms) for each Event (factorial with 2 levels)
- Random smooth for each Subject
- Random intercept for each subject (additional random intercept)

It is very slow (2/3 days) but in works perfectly.

```
brm(mean_pupil ~ Events*Trials
+ s(Time, by = Events, k=8)
+ s(Time, Subject, bs = 'fs', m=1)
+ (1|Subject),
data = db, family = student,
chains = 4, cores= 4,
backend = "cmdstanr", threads = threading(2),
iter = 8000, warmup = 6000,
control=list(adapt_delta=0.99, max_treedepth = 12))
```

The second model is very similar with some changes:

**Interaction between Event (variable of interest; factorial with 2 levels) and Gen (factorial with 2 levels)****controlling for Trials (number)**- Smooth term on time (ms) for each Event (factorial with 2 levels)
**Smooth term on time (ms) for each Gen (factorial with 2 levels)**- Random smooth for each Subject
- Random intercept for each subject (additional random intercept)

The second model is slightly more complex and unfortunately, we have to rely on less data (13969 datapoints instead of 26108).

When I run my second model I incur in some problems. I am trying to figure out how to solve them but I am not sure what could be the cause and where to start really.

```
brm(mean_pupil ~ Events*Gen+Trials
+ s(Time, by = Events, k=4)
+ s(Time, by = Gen, k=4)
+ s(Time, Subject, bs = 'fs', m=1) # Smooth random effect
+ (1|Subject), # Random effect
data = df, family = student,
chains = 4, cores= 4,
backend = "cmdstanr", threads = threading(2),
iter = 16000 , warmup = 1000,
control=list(adapt_delta=0.99, max_treedepth = 12))
```

The output of the models is:

Warning: 16000 of 16000 (100.0%) transitions hit the maximum treedepth limit of 12.

and

Parts of the model have not converged (some Rhats are > 1.05). Be careful when analysing the results! We recommend running more iterations and/or setting stronger priors.

As you can see I have already increased the number of iterations and treedepth but I am not sure if my problem could be caused by any other thing. I could increase the treedepth but everything would be even slower so I was trying to understand if there is something wrong with the specification of my model before running such an â€śexpensiveâ€ť model again.

Would anyone have any idea/solution?

Thank you a lot!

- operating system: I run the model on my windows machine and the university HPC cluster
- brms Version: 2.18.1/2.18.0