Dear everyone,
I am very new to Bayesian stats and even newer to Stan/brms.
So i guess my question is basic; I apologize for that already…!
I am first trying to re-create an analysis that was performed by a colleague in Python using pyMC3. So the question is not whether the priors and model make sense, but about how I can translate it to Stan/brms.
I have the following 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")
The model is described in the accompanying graph (as PDF).
For now, I have this unfinished model (“work in progress”):
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)) # sigma
I have three questions:
-
How do I define the priors for the interaction (M)?
-
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 thedpar
argument (= sigmaX
)?
But then, what would be theclass
for theprior()
statement?
I have also realized that priors do not necessarily need to be specified in the model. I guess default values will be used.
3) How can I find out what priors will be used for a given model? Is it what the function get_prior()
is for? Do I run it before or after brm()
?
I have tried to search online for that, but I found it very difficult to know what and where to search since I am not familiar with many of the technical terms.
I would be very grateful if you could help me with that, and also point me to some useful resources.
Thank you in advance!
Bayesian-model_brushing.pdf (33.3 KB)