Brms / non-linear models / correlated random effects

Hi!

I am wondering how I can fit correlations between random effects in non-linear models. For example:

fit_loss <- brm(
  bf(cum ~ ult * (1 - exp(-(dev/theta)^omega)),
     ult ~ 1 + (1|AY), omega ~ 1, theta ~ 1 + (1|AY), 
     nl = TRUE),
  data = loss, family = gaussian(),
  prior = c(
    prior(normal(5000, 1000), nlpar = "ult"),
    prior(normal(1, 2), nlpar = "omega"),
    prior(normal(45, 10), nlpar = "theta")
  ),
  control = list(adapt_delta = 0.9)

So ult and theta now have a random effect on the intercept…but how can I fit their correlations?

Thanks.

Sebastian

Replace (1 | AY) by (1 | ID | AY) where ID can be anything as long as it is the same across terms you want to model as correlated. See vignette("brms_multilevel") for details.

1 Like