How to predict only using the interaction terms of a variable

I have a brms model with several variables, I have also a variable, say x interacting with a bunch of other variables (w, y, z). I would like to predict using only x and its interactions, for example the model is

y ~ x*(w + v + z) + a + b +c

I fit the model for all variables and then I just want the value of the posterior of the predictor of x*(a+b+c) , for all my data points, considering that I am only using fixed effects. Reconstructing the interaction data matrix and then multiplying it by the posterior over the coefficients seems like a daunting task.

How can achieve this more straightforwardly in BRMS?

Best regards,

You need to pick what values to set the other variables to. Set them to zero? Set them to their means? Average over them in some sort of post-stratified way?

The straightforward thing, and the only thing that really makes sense in the context of your desire to drop the interactions of (a + b + c) with (w + v + z) is to set w, v, and z to zero in the prediction step. Do this by passing newdata to predict.brmsfit()

Thank you, I just realised that my question did not really matched my problem, I edited to better reflect my objectives

Sorry for the confusion

Cool. Just pass newdata to posterior_linpred, with a, b, and c all zeroed out.

1 Like

Hi sorry, for coming back this late, but before closing the issue I just want to be sure of one thing,

if I understand BRMS syntax well the modelwith x*(w+v+z) I will basically be doing (omitting the coefficients):

x + w + v + z + xw + xv + xz, is there a way to get the model that just gives me:

xw + xv + x*z

without having to explicitly write the interactions, as I have many variables. In other words, can I use x*(w+v+z) syntax and be sure that I am only modeling the pairwise interactions?

Thank you again in advance.

brms syntax is based on R formula syntax. Check out the : notation; see R: Model Formulae