Struggling with smoothed variable in bayesian model with interaction and random terms

Hello everyone,

I tried several things but am too confused and need expert advice.

We are studying motor learning in which task there is a segment of trajectory that is repeated over all trials.

Thus, we have two variables:

  • segment (repeated or not 5 levels)
  • repetition (36 trials)
  • segment-length as covariate (we want this effect to be withdrawn)

I am using brms in R which models through stan.

  f2RMSE <- bf(RMSE ~ segment*repetition + (1 + segment*repetition  | subjects))
  m2RMSE <- brm(f2RMSE , data = data2, prior = pr, sample_prior = TRUE, save_pars = save_pars(all=TRUE), iter=5000)

Because we know that the repetition effect on performance (RMSE) will take some repetition to take effect, and might not change towards the end, we would like to use smooth model on repetition to have a sigmoid like feature.
But I struggle to fully understand how to use the s() function.

Should my model be like this :
RMSE ~ segment * s(repetition) + segmentLength + (1 + segment * s(repetition) + segmentLength | subjects)

or like this ?
RMSE ~ segmentLength + segment*repetition + s(subjects, bs = ‘re’) + s(subjects, repetition, bs=‘re’) + (0 + segment + segmentLength | subjects)
Thanks for any help

Anybody got insight regarding modelling using smoothed variables ?
We tested such a model :
RMSE ~ segment + s(repetition, bs = "cs") + s(repetition, by = segment, bs = "cs") + (1 + segment * repetition | subjects).
But the interaction’s random effect is identical as the fixed effect.

We are currently testing these two models :
RMSE ~ segment + s(repetition, by = interaction(segment)) + s(repetition, subjects, bs = "fs") + (1 + segment | subjects).
And
RMSE ~ segment + s(repetition, by= interaction(segment,subjects)) + (1 + segment | subjects).

But as it takes hours for each of our models, we would love some finer understanding of the the way models are encoded.

Hi @sboylan,

I think your chances of getting feedback will improve if you are a bit more descriptive about your project.

For someone without domain knowledge this is a very opaque sentence:

You also say:

repeated or not suggests a binary variable, which is then hard to reconcile with having 5 levels.

Finally what do you mean by “we want this effect to be withdrawn”?

1 Like