Can the SD of a random effect be set to zero in one group only?

Hi all, I am new to brms, but it seems amazing!

I hope this isn’t a silly question, but I am trying to fit a crossed random effects model in which the variance of a random effect depends on the level of the predictor variable. I came across the following, which is what brought me to brms in the first place: Allowing the variance of random effects to vary as a function of categorical covariates · Issue #365 · paul-buerkner/brms · GitHub

To provide more detail, I am comparing 3 groups in terms of some outcome variable. The groups correspond to different machines. Each machine is operated by a person on a tooth, producing a value of the outcome variable. 50 people will use Machine 1 on a set of 20 teeth. The same 50 people will use Machine 2 on the same set of 20 teeth. However, it is known that for a given tooth, Machine 3 always produces the same value of the outcome variable, regardless of who operates it. Therefore, only one person (not part of the original 50) will use Machine 3 and will apply it to each of the 20 teeth. There is no need for anyone else to use Machine 3, given that Machine 3 always produces the same value for a given tooth. I would like to fit a mixed-effects model predicting the outcome with “Group” as the predictor variable, “Tooth” as a random effect for all 3 machines, and “Person” as a random effect only for Machines 1 and 2. (Equivalently, the standard deviation of the random effect of “Person” would be zero, or some number close to zero, for Machine 3.)

I was wondering if this type of analysis would be possible with brms, and if so, how to do it. Any help would be most appreciated. Thank you for taking the time to read my post!

Were you thinking of fitting random slopes while using machine as a categorical predictor?

I don’t necessarily understand exactly the data structure, but at first pass, maybe:

brm ( y ~ 1 + machine2 + machine3 + (1 + machine2 + machine3 | tooth) + (1 + machine2 | personID)
1 Like

Hi Jeremy,

Thank you so much! Yes, that worked–you have saved the day! Sincere thanks again!!

1 Like