Hierarchical priors

I am still very new to Bayesian stats and even more to Stan/brms.

I would like to specify hierarchical priors, as explained in my question 2 of this thread.
The attached diagram also shows the model I would like to implement.
Bayesian-model_brushing.pdf (41.8 KB)

I have seen quite a few threads on that topic here, but all the threads just give some code to solve the problem. I would need to have some more basic documentation of how it works; currently I do not understand how to implement it.

Where can I find such information? I had seen a pointer to the brms_nonlinear vignette, but I don’t see any mention of hierarchical priors there. It might be there, but it is not obvious to the newbie I am…

Thank you in advance!

Morning. If you could write up the brms and stan code for the model that would be a good place to start. For priors they really need to come from your subject area knowledge.

That’s how far I’ve come:

Here my data

my_data <- structure(list(Material = c("Flint", "Flint", "Flint", "Flint", "Flint", "Flint", "Flint", "Quartzite", "Quartzite", "Quartzite", "Quartzite", "Quartzite", "Quartzite", "Quartzite", "Quartzite"), Brush_Dirt = c("No_Brush_No_Dirt", "No_Brush_Yes_Dirt", "No_Brush_Yes_Dirt", "Yes_Brush_No_Dirt", "Yes_Brush_No_Dirt", "Yes_Brush_Yes_Dirt", "Yes_Brush_Yes_Dirt", "No_Brush_No_Dirt", "No_Brush_No_Dirt", "No_Brush_Yes_Dirt", "No_Brush_Yes_Dirt", "Yes_Brush_No_Dirt", "Yes_Brush_No_Dirt", "Yes_Brush_Yes_Dirt", "Yes_Brush_Yes_Dirt"), Z = c(0.244351382982314, -0.0015361217248987, -0.877775019539761, -0.498374272882404, -0.659639015247898, 0.488286794228672, -0.794444097789949, 0.909867363652624, 2.05669202585517, 0.019788897546955, 1.31082564239473, -0.0230158910253944, -0.62363353368801, 0.498543577208916, -2.04993773197107)), row.names = c(NA, 15L), class = "data.frame")

And the (unfinished) brms model:

fit <- brm(data = my_data, family = gaussian,  
Z ~ 1 + Material * Brush_Dirt,
           prior = c(prior(normal(0, sigma0), class = Intercept),                    # beta0
                     prior(normal(0, sigma1), class = b, lb = 0, coef = Material),   # beta1
                     prior(normal(0, sigma2), class = b, lb = 0, coef = Brush_Dirt), # beta2
                     prior(uniform(0, ErrorMax), class = sigma))

I now know more or less how to define the priors for the interaction (M), but the remaining question is:
How do I define the priors for sigma0, sigma1, sigma2 and sigmaM [~HN(0, sX)]? Do I need several formulas with the bf() function (one for each sigmaX) and specify the dpar argument ( = sigmaX )?
But then, what would be the class for the prior() statement?

(Sorry for the formatting of the previous version)

Maybe I don’t quite understand your model, but it seems to me that you have only one “level” of priors.
I would need priors on the priors, e.g. β0 ~ N(0, σ0) and σ0 ~ HN(0, 1). I still haven’t found how to define the priors for e.g. σ0. Or do you mean it is what the class “sd” is for?
It’s all very confusing to me and I find the documentation to be really lacking on that aspect…