# Plate notation for a hierarchical regression model (bayesian)

I've been recently studying hierarchical bayesian regressio (with pymc3), and I was wondering, how does the following example:

http://twiecki.github.io/blog/2014/03/17/bayesian-glms-3/

look like when shown in plate notation?

For reference, the model is defined as:

$\textrm{radon}_{i} = \alpha_{c}+\beta_{c}*floor_{i,c}+\epsilon_{c}$,

where for the final model,

$\alpha_{c} \sim \mathcal{N}(\mu_{\alpha},\sigma_{\alpha})$ and $\beta_{c} \sim \mathcal{N}(\mu_{\beta},\sigma_{\beta})$, i.e., the coefficients all come from a common group distribution.

Thank you!

• Would you mind copying down the model here for easy reference? – tddevlin Jun 29 '18 at 22:02
• We actually just added plate notation graphs to the library and updated this very example. See docs.pymc.io/notebooks/multilevel_modeling.html . – colcarroll Jun 30 '18 at 20:37

According to the comment by @colcarroll, the updated example with plate models is indeed given in: https://docs.pymc.io/notebooks/multilevel_modeling.html This corresponds to the PyMC3 model:

with pm.Model() as hierarchical_model:
# Hyperpriors
mu_a = pm.Normal('mu_alpha', mu=0., sd=1)
sigma_a = pm.HalfCauchy('sigma_alpha', beta=1)
mu_b = pm.Normal('mu_beta', mu=0., sd=1)
sigma_b = pm.HalfCauchy('sigma_beta', beta=1)

# Intercept for each county, distributed around group mean mu_a
a = pm.Normal('alpha', mu=mu_a, sd=sigma_a, shape=len(data.county.unique()))
# Intercept for each county, distributed around group mean mu_a
b = pm.Normal('beta', mu=mu_b, sd=sigma_b, shape=len(data.county.unique()))

# Model error
eps = pm.HalfCauchy('eps', beta=1)

# Expected value
radon_est = a[county_idx] + b[county_idx] * data.floor.values

# Data likelihood