Multilevel models: Pooling parameters on several levels

Hi! I was actually wondering: Is it possible to pool parameters at several levels in multi-level linear regression models in pymc3? For example, I have a dataset consisting of seven studies and the samples in each of these studies can be split into two groups (e.g. younger and older). Therefore, I could divide the entire dataset in 14 groups. I’d now like to first pool parameters for all 7 younger groups as well as 7 older groups and then pool parameters for younger and older - is it possible to implement this scenario in pymc3?

1 Like

Hi Anna!
I think in theory you can add as many levels as you want – as a level is just another line of priors. In practice though, models become very hard to interpret (and I’d guess to sample) as you add more layers.

Here actually, I wonder if you really need two levels: I think you need two types of clusters – maturities and studies. The first cluster allows you to model both groups (youngs and olds) while also pooling information across these, thus infering the whole population. The second cluster is here to take into account any other study-specific variation.

Is it what you’re after? If yes, you’ll find examples of how to do it in PyMC in this NB – it’s a port of the appropriate chapter in McElreath’s book.
Hope this helps :slight_smile:

1 Like

Hi Alex! Thanks so much for the fast reply! And the idea of just considering two clusters - somehow hadn’t thought of this option earlier and it actually solved my problem immediately! Thanks :grinning:

1 Like

Glad I could help. Enjoy building the model :slight_smile:

1 Like