Hey Max - thanks for the quick reply!

On the `(...||...)`

syntax - I thought that just means the slopes/ intercepts are not correlated with other slopes/ intercepts between groups? From p.3 here: https://journal.r-project.org/archive/2018/RJ-2018-017/RJ-2018-017.pdf

For instance, if the userwere to write `(1 | g1/g2)`

,brms will expand this to `(1 | g1) + (1 | g1:g2)`

. Instead of `|`

, usersmay use `||`

in grouping terms to prevent group-level correlations from being modeled.

…

The solution implemented inbrms(and currently unique to it) expands the `|`

operator into `|<ID>|`

, where `<ID>`

can be any value. Group-level terms withthe same `ID`

will then be modeled as correlated if they share same grouping factor(s). For instance, if the terms `(x1|ID|g1)`

and `(x2|ID|g1)`

appear somewhere in the same or different formulas passed to brms, they will be modeled as correlated.

So based on the above, I used the `||`

to make sure that the fixed intercept for each county would be uncorrelated to each other. Perhaps I’ve over complicated things?

And yes - the model should reflect the hierarchical structure in the picture.

In terms of your suggested formula, the syntax makes sense uner `lme4`

. However, looking at the same page in the doc linked above:

We propose that group can generally be split upin its terms so that, for example, `(1 | g1 + g2)`

is expanded to `(1 | g1) + (1 | g2)`

. This is fully consistent with the way `/`

is handled and provides a natural generalization to the existing syntax.

Would that not suggest that `(1 | g1) + (1 | g2)`

is same as `(1 | g1/g2)`

and `(1 | g1 + g2)`

? Or are the latter 2 terms not equivalent? I found another post, where the hierarchical formulation seems to suggest the `/`

operator isn’t needed. Or perhaps that was only used in the case of multi-membership at level 2?

In addition, if `(1 | country/region/counties)`

looks at the fixed intercept + random slope for each county (relative/ differences to the intercept) nested underneath the country and region, would it not be the same as `(0 + counties | country/region)`

with a random slope per each county category with no intercept?

With regards to my 2nd question, if I formulate as per your suggested syntax, I see the following stancodes in the model portion:

```
vector[N] nlp_Modifier = X_Modifier * b_Modifier;
// initialize non-linear predictor term
vector[N] mu;
for (n in 1:N) {
// add more terms to the linear predictor
nlp_Modifier[n] += r_1_Modifier_1[J_1[n]] * Z_1_Modifier_1[n] + r_2_Modifier_1[J_2[n]] * Z_2_Modifier_1[n] + r_3_Modifier_1[J_3[n]] * Z_3_Modifier_1[n];
}
for (n in 1:N) {
// compute non-linear predictor values
mu[n] = log(C_1[n]) + nlp_Modifier[n];
}
// priors including all constants
target += student_t_lpdf(sigma | 3, 0, 10) - 1 * student_t_lccdf(0 | 3, 0, 10);
target += student_t_lpdf(sd_1 | 3, 0, 10) - 1 * student_t_lccdf(0 | 3, 0, 10);
target += normal_lpdf(z_1[1] | 0, 1);
target += student_t_lpdf(sd_2 | 3, 0, 10) - 1 * student_t_lccdf(0 | 3, 0, 10);
target += normal_lpdf(z_2[1] | 0, 1);
target += student_t_lpdf(sd_3 | 3, 0, 10) - 1 * student_t_lccdf(0 | 3, 0, 10);
target += normal_lpdf(z_3[1] | 0, 1);
```

What would actually be needed to put a specific prior for a given group value…? I can see that the grouping value is for example stored in `J_3[n]`

, which in turn feeds the `r_3_Modifier`

and the `nlp_Modifier`

, but not sure how to proceed…

Hopefully once the priors are changed, I can just follow this to re-fit in brms.

Sorry for the long reply - am still getting my head around the way that brms’ syntax and its generated code work!

Thanks again - much appreciated!