Hierarchical modeling categorical variable interactions in PyMC3 -


i'm attempting use pymc3 implement hierarchical model categorical variables , interactions. in r, formula take form of like:

y ~ x1 + x2 + x1:x2 

however, on tutorial https://pymc-devs.github.io/pymc3/glm-hierarchical/#partial-pooling-hierarchical-regression-aka-the-best-of-both-worlds explicitly glm doesn't play nice hierarchical modeling yet.

so how go adding x1:x2 term? categorical variable 2 categorical parents (x1 , x2)?

you can manually add interaction term linear model. have add 3 regression coefficients (betas) , 1 intercept. can estimate y likelihood follows:

y = pm.normal('regression',                 mu=intercept + beta_x1 * data_x1 + beta_x2 * data_x2 + beta_interaction * data_x1 * data_x2,                 sd=sigma,                 observed=data_y) 

the parameters can have hyperpriors build hierarchical model.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -