# How to specify correlated random effects in zero_inflated beta model in brms

Dear brms Users,

Suppose I am running the following model in brms;

``````brm(
formula = bf(
y ~ 1 +x1+x2 + (1|ID1)+(1|ID2),
zi ~ 1 +x1+x2 + (1|ID1)+(1|ID2)
),
family = zero_inflated_beta,
data = df
)
``````

Is it possible to specify correlated random effects such that the random effects specified in the y~… statement are correlated with the random effects specified in the zi~… statement? i.e for the two parts to be correlated. e.g if you expect that absence/presence (the binary part) influences the value of the nonzero part.

• brms Version: 2.16.1

Kindly assist. Thank you!

You might try this.

``````brm(
formula = bf(
y ~ 1 +x1+x2 + (1 |a| ID1)+(1 |b| ID2),
zi ~ 1 +x1+x2 + (1 |a| ID1)+(1 |b| ID2)
),
family = zero_inflated_beta,
data = df
)
``````
1 Like

Hi Solomon,

Thank you very much. I think that will do it. But quick question; can the a and b be anything? e.g Can I specify a=2 ; b=4 outside of brm?

Thanks again.

Yes, I believe `a` and `b` can be any number of things. I don’t think it matters if they have been assigned values outside of the `brm()` code. But then again, I’ve never checked. It might be worth it to confirm by running a reduced model (to reduce estimation time). Something like:

``````a <- 5

brm(
formula = bf(
y ~ 1 + (1 |a| ID1),
zi ~ 1 + (1 |a| ID1)
),
family = zero_inflated_beta,
data = df
)
``````