Multiple correlation structures in hierarchical models using brms

Hello,

Could someone please help me with the following situation? It would be great.

I’m modelling an outcome as a function of five level 1 covariates (population level) and one level 2 covariate (group level). The model is a hierarchical linear regression with cross-level interactions between the level 2 covariate and four of the five level 1 covariates. The five level 1 covariate also depend on a grouping variable, so that I have a random intercept as well as random slopes.

So far so good, everything works. The thing is that I would like to not have the correlation between certain pairs of my level 1 covariates. I would like correlations between the intercept and one level 1 covariate, two other level 1 covariates and the intercept, and between the intercept and the two last covariates: so three distinct correlation matrices.

I tried using the | ID | notation, but apparently did it wrong, as I’m getting an error message telling me that “Duplicated group-level effects are not allowed”.

Here is the model that works fine, but calculates a correlation structure among all level 1 covariates (while some of the pairs are of no interest). LMA is the level 2 covariate.

prior_brms <- c(prior(normal(0, 2), class = “Intercept”),
prior(normal(0, 2), class = “b”),
prior(normal(0, 2), class = “sd”)) # class ‘sd’ already internally has a lower bound at 0

fit_brms <- brm(formula = agr ~ var1 + var2 + var3 + var4 + var5 + LMA +
var2:LMA + var3:LMA + var4:LMA + var5:LMA +
(1 + var1 + var2 + var3 + var4 + var5 | species) +
(1 | individual) + (1 | plot) + (1 | period),
data = data2,
family = gaussian(),
prior = prior_brms,
warmup = 1000,
iter = 2000,
chains = 4,
cores = 4,
seed = 42,
control = list(adapt_delta = 0.99, max_treedepth = 15))

My (apparently poor) attempt to do what I was describing above (multiple correlation structures) was:

fit_brms_corr <- brm(formula = agr ~ var1 + var2 + var3 + var4 + var5 + LMA +
var2:LMA + var3:LMA + var4:LMA + var5:LMA +
(1 + var1 | ID1 | species) + (1 + var2 + var3 | ID2 | species) +
(1 + var4 + var5 | ID3 | species) +
(1 | individual) + (1 | plot) + (1 | period),
data = data2,
family = gaussian(),
prior = prior_brms,
…)
I would therefore like to obtain the correlation between the level 1 covariate coefficients:

  • intercept and var1
  • intercept, var2, var3
  • intercept, var4, var5
    but not var1 with any of the other level 1 covariates, nor var2 or var3 with var4 or var5.

I hope this was clear enough.

In advance thank you for any advise.

David

  • Operating System: Microsoft Windows 10 Pro
  • brms Version: 2.8.0

Hi, I don’t have a ton of time to look at this right now, but I can give you a quick thing to look at.

The notation:

(1 + 1 | ID | group) 

allows you to ensure the groups are correlated (ie treated as the same groups) across different parts of a formula, for example in a multivariate response, models with non-linear parts, or zero inflation models that include group levels as predictors of the zero inflation part.)

If you have population level effects that you don’t want to be modeled as correlated with group level effects there is notation for that. for instance if you do want var1, var2 and var3 to be correlated with species, but var4 not to be your notation for the grouping part would look like

(1 + var1 + var2 + var3 | species) +
(1 + var4 || species)

Hope that helps until someone else/someone smarter comes along or until I have time to give it more thought ! :)

If I have misunderstood your problem clarify it a little and let me know.

1 Like

Hi Meg,

Thank you for taking the time to help me.

What you suggest ( (1 + var1 + var2 + var3 | species) + (1 + var4 || species)), however, does not work, as it gives me the following message:
Error: Duplicated group-level effects are not allowed.
Occured for effect ‘Intercept’ of group ‘species’.

Moreover, I don’t think this totally encapsulate what I’d like to do, as my objective here is to discover how to code that (1) the coefficients of var1, var2, var3, var4 and var5 (level 1 covariates) all depend on the group ‘species’ (varying or random slopes), but (2) I only want the model to include the correlation between 1 (the intercept) and var1, between 1, var2, and var3, and between 1, var4 and var5. I have no biological/ecological reason to consider the correlation between var2 and var4, for example, and so on.

I hope I made things clearer. :-)

Thank you very much.