3
$\begingroup$

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!

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

1 Answer 1

2
$\begingroup$

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

hierarchical plate model

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
    y_like = pm.Normal('y_like', mu=radon_est, sd=eps, observed=data.log_radon)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.