Predictions in brms (partial ignore some of the random effects in fitted())

Hi

I have a multilevel model with three levels: study, run and the error term. I would like to have the predicted means by study but ignoring the run.

mod <- brm(Result~Stabtime:Condition+(1|RunID)+(1|Study),data=.,
save_ranef = TRUE, chains = Chains, iter = Iter,
warmup = Warmup, thin = Thin)

If I want the overal predicted mean, I use

PrebM <- fitted(mod,scale=“response”,re_formula = NA)

  • This will ignore the variability of Run and Study but I want to just ignore the variability of only Run. How can I do this using the re_formula or any other approach?

Kind regards,

Luwis

You can specify the varying effects as a formula in re_formula. So I think you can try

PrebM <- fitted(mod, scale = "response", re_formula = ~(1 | Study))

Hope that helps

1 Like

Dear Matti

Thanks.

Kind regards,

Luwis

2 Likes