Nested Hierarchical Model


I am a pymc3 newbie and need some guidance to handle nested hierarchical data. I am trying to port a BRMS model from R which has the following lme4 formula

y ~ x1 + x2 + x3 + (1 | x4/x5) -

where the (1 | x4/x5) notation means that the intercept can vary between x4 and also for all the x5 contained within x4. For a more detailed explanation of this notation please refer to pg.7

To take a simple example, let’s consider the radon dataset ( where instead of simply focusing on the Minnesota state, we develop a model for all states and then handle counties within those states with a suitable hierarchical formulation.

How to define hyperpriors for such models?

1 Like

No very familiar with this (1 | x4/x5) notation, but if you are using brms you can export the Stan code, and usually mapping the Stan code to the PyMC3 code should be straightforward