Multinomial model with spline and interaction - getting output from continous and categorical variable together


I am having issues with extracting specific output from the brms function. I want to model how the probability of being in one of three categories changes with both age and sex of an individual. But the output from brms is either how it changes with age or how it differs based on sex and not a combination of the two. So my question is whether there is a way to get that from the model output?

I am working on a model with a categorical (multinomial) response that has three possible outcomes and a continuous and a categorical explanatory variable. I am modelling the continuous variable (age) as a spline to allow for a non-linear relationship and the continuous variable can change differently depending on the categorical variable (2 levels, males and females).

m1 ← brms(y ~ s(age by = sex, bs = “tp”) + s(sex, bs = “re”),
data = df,
family = categorical, …)

I have tried to model this with a binomial response instead and modelled three separate models for each of the categories of the response. For this model, I am able to get the output of how the response changes with both age and sex. But I would like to get it to work as a multinomial model instead.

Let me know if there is other information needed to understand the question!
Thank you,

Hi and welcome, and sorry for the late reply,

I am not familiar with how brms works under the hood, but I am guessing there is a qualitative difference between a binomial likelihood, where you may just have to specify a probability p (provided that the N in the binomial is something you have the data on), and a categorical variable, where you have to appropriately specify probabilities for each category. This makes me think that maybe you could use a multinomial likelihood instead of categorical and get the result you want (since that would be the “multicategory” equivalent to the binomial, and bernoulli would be the 2-category equivalent to a generic categorical variable).
In any case, you may want to check what the differences in the formulation actually are and what describes your system best (and make sure what brms is doing is what you expect it to).