Hi All,

I am trying to model some pupillometry data that I collected from one of my studies.

I have already modelled the data using mgcv and I woudl like to convert the model to brms.

I am new to both brms and mgcv so please forgive me if this is a stupid question.

From what I could read I think the model specification should be the same but I am not totally sure about the random effect part.

What I am trying to do is model the pupil data to have:

- 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

the model I run on mgcv is:

```
m1 <- bam(mean_pupil ~ Events*Trials
+ s(Time, by = Events, k=20)
+ s(Time, Subject, bs = 'fs', m=1),
data = prediction, discrete = TRUE,
family = scat)
```

my interpretation on how I should port the model the brms is simply:

```
mod2 = brm(mean_pupil ~ Events*Trials
+ s(Time, by = Events, k=20)
+ s(Time, Subject, bs = 'fs', m=1) , data = prediction,
family = student, seed = 17, cores= 4,
iter = 2000, warmup = 1000, thin = 10,
control = list(adapt_delta = 0.99))
```

Is the model conversion correct? Is this the way to specify a random smooth for each participant also in brms?

Also I am wondering if there is a way to speed up the model since when I try to run the model it takes around 16h (the dataframe has just 29768 obs)?

In case someone is interested I built the models thanks to this two helpful tutorials:

Thank you a lot !

```
Operating System : windows 10
brms Version : 2.18.0
```