Generating random slopes for subtypes of a covariate without the reference

Hello everyone,
I am trying to build a model where the population level covariate will have random slopes only based on subtypes of that covariate however the issue I have with this is that the random effects include the reference level of those ‘subtypes’ as a parameter as well which I do not want since that does not make sense. I made a little mock example as shown below:


df <- data.frame(feeling_happy=rbinom(5000,0:1,0.3), ice_cream=rbinom(5000,0:1,0.2)) %>%
 mutate(ice_cream_type=ifelse(ice_cream==1,sample(1:6, replace=T),0))
model <- brm(feeling_happy ~ ice_cream + (0 + ice_cream | ice_cream_type),family=bernoulli(),
 data=df, cores=1, chains=1, iter=1000, backend='cmdstanr') 

In this example, I would like to have different slope for each ice cream type however I do not want a parameter for when ice cream type equals 0 which would mean that the ice cream covariate is 0. Thank you so much for your help!

  • Operating System: x86_64-pc-linux-gnu (64-bit)

  • brms Version: 2.18.0