Bambi's hierarchical modeling #808
-
Hello everyone, I have a question regarding the theory behing bambi and specificly hierarchical modeling. In traditional hierarchical Bayesian modeling, it is customary to incorporate hyper-priors to ensure that the resulting prior adequately captures the average effect across all categories. However, upon reviewing the implementation in Bambi, for example here, I noticed that there is only one prior specified for sigma. This raised a question regarding the absence of a hyper-prior on mu. ![]() Could you help me elucidate the reason of this choice ? Thanks a lot ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 17 replies
-
Hi @MatteoBenaud this is a great question and it's actually something I wanted to incorporate into our docs for a long time. I'll make an attempt at explaining how it works. Bambi, as most (or all?) formula based interfaces, have some frequentist flavor when doing hierarchical (mixed, multi-level, etc.) modeling. In frequentist stats a mixed effects models for the mean (fixed and random effects) is written as follows The first dot product represents the fixed effects and the second dot product represents the random effects. Bambi is always following this same structure. Let's present a simpler example. Let's imagine we have J groups and we want partially pooled intercepts. Using distributions we can write this model as So each group has its own mean However, this is not the only way we can write this model. Have a look at the following: Notice the This is the reason why you see I don't want to extend too much here. I think the main idea is summarized above, but please feel free to ask for further clarification :) |
Beta Was this translation helpful? Give feedback.
I'm afraid it's not possible to implement that model in Bambi because of:
c
,z
, andy
)z
andc
go intoy_mu
).It's possible one could write a custom family that hacks through Bambi internals and implements this PyMC model. But if one is willing to do such amount of work, it's just simpler to use plain PyMC.