Dear Stan Users and Creators,

I am trying to solve the following modeling problem with brms and loo:

Consider a simple linear regression model, where I predict some numerical variable y with another numerical variable x. This is estimated in two groups. For simplicity, I assume that these are female (group = 1) and male respondents (group = 0). y, x and group are stored in an R data frame df.

In my model, I assume that the slope parameter is gender-specific, but that the intercept parameter is not. To estimate such a model in brms, I used the following syntax to first obtain two group-specific predictors:

df$xm β df$x * (1 - df$group)

df$xf β df$x * (df$group)

I then estimated the following model:

model_common β brm(

formula = y ~ xm + xf,

data = df

)

As a next step, I would like to use cross-validation between the two groups. The basic idea is to obtain a check whether the posterior for the intercept parameter is stable over both groups. The obvious challenge is that the predictor variables are now group-specific. My solution would be to first estimate the following two models:

model_m β brm(

formula = y ~ xm,

data = df[group == 0,]

)

model_f β brm(

formula = y ~ xf,

data = df[group == 1,]

)

The next step would be to replace the posteriors for the intercept parameter in model_m and model_f with the posterior from model_common, and evaluate the resulting model using the raw data. My question is if there is an easier way to do this, e.g. using some functionality from the loo package? As far as I have seen, this is not the case, but maybe I am overlooking something.